SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/RayTracer/BackgroundSpacetimes - BackgroundSpacetime.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 35.3 % 17 6
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 <cstddef>
       7              : #include <memory>
       8              : #include <optional>
       9              : #include <pup.h>
      10              : #include <utility>
      11              : #include <vector>
      12              : 
      13              : #include "DataStructures/DataBox/Prefixes.hpp"
      14              : #include "DataStructures/TaggedTuple.hpp"
      15              : #include "DataStructures/Tensor/Tensor.hpp"
      16              : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      17              : #include "PointwiseFunctions/Hydro/Tags.hpp"
      18              : #include "Utilities/Serialization/CharmPupable.hpp"
      19              : #include "Utilities/TMPL.hpp"
      20              : 
      21            0 : namespace ray_tracing {
      22              : 
      23              : /*!
      24              :  * \brief Abstract base class for background spacetimes in the ray tracer.
      25              :  *
      26              :  * Derived classes have to provide spacetime quantities at a given point on
      27              :  * request, e.g. by evaluating an analytic spacetime or by interpolating numeric
      28              :  * data from a file. The `initialize` function can be used to set up the
      29              :  * background spacetime, e.g. by reading data from a file. Then, the background
      30              :  * spacetime should be valid within the bounds returned by the `time_bounds`
      31              :  * function.
      32              :  */
      33            1 : class BackgroundSpacetime : public PUP::able {
      34              :  protected:
      35            0 :   static constexpr size_t Dim = 3;
      36            0 :   using DataType = double;
      37            0 :   using Frame = ::Frame::Inertial;
      38            0 :   using DerivLapse =
      39              :       ::Tags::deriv<gr::Tags::Lapse<DataType>, tmpl::size_t<Dim>, Frame>;
      40            0 :   using DerivShift =
      41              :       ::Tags::deriv<gr::Tags::Shift<DataType, Dim>, tmpl::size_t<Dim>, Frame>;
      42            0 :   using DerivInvSpatialMetric =
      43              :       ::Tags::deriv<gr::Tags::InverseSpatialMetric<DataType, Dim, Frame>,
      44              :                     tmpl::size_t<Dim>, Frame>;
      45            0 :   using DerivSpatialMetric =
      46              :       ::Tags::deriv<gr::Tags::SpatialMetric<DataType, Dim, Frame>,
      47              :                     tmpl::size_t<Dim>, Frame>;
      48              : 
      49            0 :   BackgroundSpacetime() = default;
      50              : 
      51              :  public:
      52            0 :   ~BackgroundSpacetime() override = default;
      53              : 
      54              :   /// \cond
      55              :   explicit BackgroundSpacetime(CkMigrateMessage* msg) : PUP::able(msg) {}
      56              :   WRAPPED_PUPable_abstract(BackgroundSpacetime);
      57              :   /// \endcond
      58              : 
      59              :   /// Copies the background spacetime. Must call `initialize` on the clone
      60              :   /// before using it.
      61            1 :   virtual auto get_clone() const -> std::unique_ptr<BackgroundSpacetime> = 0;
      62              : 
      63              :   /*!
      64              :    * \brief Initialize the background spacetime, e.g. by reading data from a
      65              :    * file.
      66              :    *
      67              :    * This function is called before the first call to `variables()`. It is
      68              :    * valid to call `initialize` again with new time bounds. Derived classes
      69              :    * must guarantee that the `variables` function can be called from other
      70              :    * threads while `initialize` is running (e.g. loading new data from files),
      71              :    * but only with times within the overlap of the previous and the new time
      72              :    * bounds.
      73              :    *
      74              :    * \param time_bounds The time bounds for which to initialize the
      75              :    * background spacetime. The spacetime should be valid for all times in this
      76              :    * range.
      77              :    */
      78            1 :   virtual void initialize(
      79              :       [[maybe_unused]] const std::array<double, 2> time_bounds) {}
      80              : 
      81              :   /// Time bounds for which the background spacetime is valid. The `variables`
      82              :   /// function can be called for any time in this range (inclusive).
      83            1 :   virtual std::array<double, 2> time_bounds() const {
      84              :     return {-std::numeric_limits<double>::infinity(),
      85              :             std::numeric_limits<double>::infinity()};
      86              :   }
      87              : 
      88              :   /// These tags can be retrieved from the background spacetime. They are
      89              :   /// required to evaluate the `gr::geodesic_equation`.
      90            1 :   using tags = tmpl::list<gr::Tags::Lapse<DataType>, DerivLapse,
      91              :                           gr::Tags::Shift<DataType, Dim, Frame>, DerivShift,
      92              :                           gr::Tags::InverseSpatialMetric<DataType, Dim, Frame>,
      93              :                           DerivInvSpatialMetric,
      94              :                           gr::Tags::ExtrinsicCurvature<DataType, Dim, Frame>>;
      95              : 
      96              :   /*!
      97              :    * \brief Returns all spacetime variables at a given point in space and time.
      98              :    *
      99              :    * This function must be thread-safe.
     100              :    *
     101              :    * \param x Spatial coordinates
     102              :    * \param t Time
     103              :    * \param block_order Optional priority order for processing blocks during
     104              :    * interpolation. If specified, it will be updated to push the block in which
     105              :    * the point was found to the front. Can be empty, in which case it will be
     106              :    * initially set to the default order. See `block_logical_coordinates` for
     107              :    * more details.
     108              :    */
     109            1 :   virtual tuples::tagged_tuple_from_typelist<tags> variables(
     110              :       const tnsr::I<DataType, Dim, Frame>& x, double t,
     111              :       std::optional<gsl::not_null<std::vector<size_t>*>> block_order =
     112              :           std::nullopt) const = 0;
     113              : };
     114              : 
     115              : }  // namespace ray_tracing
        

Generated by: LCOV version 2.0-1