SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/AnalyticData/Xcts - Binary.hpp Hit Total Coverage
Commit: 3c072f0ce967e2e56649d3fa12aa2a0e4fe2a42e Lines: 3 52 5.8 %
Date: 2024-04-23 20:50:18
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 <limits>
       8             : #include <optional>
       9             : 
      10             : #include "DataStructures/CachedTempBuffer.hpp"
      11             : #include "DataStructures/DataBox/Prefixes.hpp"
      12             : #include "DataStructures/TempBuffer.hpp"
      13             : #include "DataStructures/Tensor/EagerMath/Magnitude.hpp"
      14             : #include "DataStructures/Tensor/Tensor.hpp"
      15             : #include "Elliptic/Systems/Xcts/Tags.hpp"
      16             : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
      17             : #include "Options/Auto.hpp"
      18             : #include "Options/Context.hpp"
      19             : #include "Options/ParseError.hpp"
      20             : #include "Options/String.hpp"
      21             : #include "PointwiseFunctions/AnalyticData/Xcts/CommonVariables.hpp"
      22             : #include "PointwiseFunctions/AnalyticSolutions/Xcts/Flatness.hpp"
      23             : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      24             : #include "PointwiseFunctions/GeneralRelativity/Tags/Conformal.hpp"
      25             : #include "PointwiseFunctions/InitialDataUtilities/Background.hpp"
      26             : #include "PointwiseFunctions/InitialDataUtilities/InitialGuess.hpp"
      27             : #include "Utilities/CallWithDynamicType.hpp"
      28             : #include "Utilities/Requires.hpp"
      29             : #include "Utilities/Serialization/CharmPupable.hpp"
      30             : #include "Utilities/Serialization/PupStlCpp17.hpp"
      31             : #include "Utilities/TMPL.hpp"
      32             : #include "Utilities/TaggedTuple.hpp"
      33             : 
      34             : /// \cond
      35             : namespace PUP {
      36             : class er;
      37             : }  // namespace PUP
      38             : /// \endcond
      39             : 
      40             : namespace Xcts::AnalyticData {
      41             : 
      42             : namespace detail {
      43             : 
      44             : template <typename DataType>
      45             : using BinaryVariablesCache = cached_temp_buffer_from_typelist<tmpl::append<
      46             :     common_tags<DataType>,
      47             :     tmpl::list<
      48             :         ::Tags::deriv<Tags::ShiftBackground<DataType, 3, Frame::Inertial>,
      49             :                       tmpl::size_t<3>, Frame::Inertial>,
      50             :         gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 0>,
      51             :         gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 0>,
      52             :         gr::Tags::Conformal<gr::Tags::MomentumDensity<DataType, 3>, 0>,
      53             :         // For initial guesses
      54             :         Tags::ConformalFactorMinusOne<DataType>,
      55             :         Tags::LapseTimesConformalFactorMinusOne<DataType>,
      56             :         Tags::ShiftExcess<DataType, 3, Frame::Inertial>>,
      57             :     hydro_tags<DataType>>>;
      58             : 
      59             : template <typename DataType>
      60             : struct BinaryVariables
      61             :     : CommonVariables<DataType, BinaryVariablesCache<DataType>> {
      62             :   static constexpr size_t Dim = 3;
      63             :   using Cache = BinaryVariablesCache<DataType>;
      64             :   using Base = CommonVariables<DataType, BinaryVariablesCache<DataType>>;
      65             :   using Base::operator();
      66             : 
      67             :   using superposed_tags = tmpl::append<
      68             :       tmpl::list<
      69             :           Tags::ConformalMetric<DataType, Dim, Frame::Inertial>,
      70             :           ::Tags::deriv<Tags::ConformalMetric<DataType, Dim, Frame::Inertial>,
      71             :                         tmpl::size_t<Dim>, Frame::Inertial>,
      72             :           gr::Tags::TraceExtrinsicCurvature<DataType>,
      73             :           ::Tags::dt<gr::Tags::TraceExtrinsicCurvature<DataType>>,
      74             :           gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 0>,
      75             :           gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 0>,
      76             :           gr::Tags::Conformal<gr::Tags::MomentumDensity<DataType, Dim>, 0>,
      77             :           Tags::ConformalFactorMinusOne<DataType>,
      78             :           Tags::LapseTimesConformalFactorMinusOne<DataType>,
      79             :           Tags::ShiftExcess<DataType, Dim, Frame::Inertial>>,
      80             :       hydro_tags<DataType>>;
      81             : 
      82             :   BinaryVariables(
      83             :       std::optional<std::reference_wrapper<const Mesh<Dim>>> local_mesh,
      84             :       std::optional<std::reference_wrapper<const InverseJacobian<
      85             :           DataType, Dim, Frame::ElementLogical, Frame::Inertial>>>
      86             :           local_inv_jacobian,
      87             :       const tnsr::I<DataVector, Dim>& local_x,
      88             :       const double local_angular_velocity, const double local_expansion,
      89             :       const std::array<double, 3> local_linear_velocity,
      90             :       std::optional<std::array<double, 2>> local_falloff_widths,
      91             :       std::array<tnsr::I<DataVector, Dim>, 2> local_x_isolated,
      92             :       std::array<DataVector, 2> local_windows,
      93             :       tuples::tagged_tuple_from_typelist<superposed_tags> local_flat_vars,
      94             :       std::array<tuples::tagged_tuple_from_typelist<superposed_tags>, 2>
      95             :           local_isolated_vars)
      96             :       : Base(std::move(local_mesh), std::move(local_inv_jacobian)),
      97             :         x(local_x),
      98             :         angular_velocity(local_angular_velocity),
      99             :         expansion(local_expansion),
     100             :         linear_velocity(local_linear_velocity),
     101             :         falloff_widths(std::move(local_falloff_widths)),
     102             :         x_isolated(std::move(local_x_isolated)),
     103             :         windows(std::move(local_windows)),
     104             :         flat_vars(std::move(local_flat_vars)),
     105             :         isolated_vars(std::move(local_isolated_vars)) {}
     106             : 
     107             :   const tnsr::I<DataVector, Dim>& x;
     108             :   const double angular_velocity;
     109             :   const double expansion;
     110             :   const std::array<double, 3> linear_velocity;
     111             :   const std::optional<std::array<double, 2>> falloff_widths;
     112             :   const std::array<tnsr::I<DataVector, Dim>, 2> x_isolated;
     113             :   const std::array<DataVector, 2> windows;
     114             :   const tuples::tagged_tuple_from_typelist<superposed_tags> flat_vars;
     115             :   const std::array<tuples::tagged_tuple_from_typelist<superposed_tags>, 2>
     116             :       isolated_vars;
     117             : 
     118             :   template <bool ApplyWindow = true, typename Tag,
     119             :             Requires<tmpl::list_contains_v<superposed_tags, Tag>> = nullptr>
     120             :   void superposition(gsl::not_null<typename Tag::type*> superposed_var,
     121             :                      gsl::not_null<Cache*> /*cache*/, Tag /*meta*/) const {
     122             :     for (size_t i = 0; i < superposed_var->size(); ++i) {
     123             :       if constexpr (ApplyWindow) {
     124             :         (*superposed_var)[i] =
     125             :             get<Tag>(flat_vars)[i] +
     126             :             windows[0] *
     127             :                 (get<Tag>(isolated_vars[0])[i] - get<Tag>(flat_vars)[i]) +
     128             :             windows[1] *
     129             :                 (get<Tag>(isolated_vars[1])[i] - get<Tag>(flat_vars)[i]);
     130             :       } else {
     131             :         (*superposed_var)[i] = get<Tag>(isolated_vars[0])[i] +
     132             :                                get<Tag>(isolated_vars[1])[i] -
     133             :                                get<Tag>(flat_vars)[i];
     134             :       }
     135             :     }
     136             :   }
     137             : 
     138             :   void operator()(
     139             :       const gsl::not_null<tnsr::ii<DataType, Dim>*> conformal_metric,
     140             :       const gsl::not_null<Cache*> cache,
     141             :       Tags::ConformalMetric<DataType, Dim, Frame::Inertial> meta)
     142             :       const override {
     143             :     superposition(conformal_metric, cache, meta);
     144             :   }
     145             :   void operator()(
     146             :       const gsl::not_null<tnsr::ijj<DataType, Dim>*> deriv_conformal_metric,
     147             :       const gsl::not_null<Cache*> cache,
     148             :       ::Tags::deriv<Tags::ConformalMetric<DataType, Dim, Frame::Inertial>,
     149             :                     tmpl::size_t<Dim>, Frame::Inertial>
     150             :           meta) const override {
     151             :     superposition(deriv_conformal_metric, cache, meta);
     152             :     add_deriv_of_window_function(deriv_conformal_metric);
     153             :   }
     154             :   void operator()(
     155             :       const gsl::not_null<Scalar<DataType>*> extrinsic_curvature_trace,
     156             :       const gsl::not_null<Cache*> cache,
     157             :       gr::Tags::TraceExtrinsicCurvature<DataType> meta) const override {
     158             :     superposition(extrinsic_curvature_trace, cache, meta);
     159             :   }
     160             :   void operator()(
     161             :       const gsl::not_null<Scalar<DataType>*> dt_extrinsic_curvature_trace,
     162             :       const gsl::not_null<Cache*> cache,
     163             :       ::Tags::dt<gr::Tags::TraceExtrinsicCurvature<DataType>> meta)
     164             :       const override {
     165             :     superposition(dt_extrinsic_curvature_trace, cache, meta);
     166             :   }
     167             :   void operator()(
     168             :       gsl::not_null<tnsr::I<DataType, Dim>*> shift_background,
     169             :       gsl::not_null<Cache*> cache,
     170             :       Tags::ShiftBackground<DataType, Dim, Frame::Inertial> /*meta*/)
     171             :       const override;
     172             :   void operator()(
     173             :       gsl::not_null<tnsr::iJ<DataType, Dim>*> deriv_shift_background,
     174             :       gsl::not_null<Cache*> cache,
     175             :       ::Tags::deriv<Tags::ShiftBackground<DataType, Dim, Frame::Inertial>,
     176             :                     tmpl::size_t<Dim>, Frame::Inertial> /*meta*/) const;
     177             :   void operator()(gsl::not_null<tnsr::II<DataType, Dim, Frame::Inertial>*>
     178             :                       longitudinal_shift_background_minus_dt_conformal_metric,
     179             :                   gsl::not_null<Cache*> cache,
     180             :                   Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
     181             :                       DataType, Dim, Frame::Inertial> /*meta*/) const override;
     182             :   void operator()(
     183             :       const gsl::not_null<Scalar<DataType>*> conformal_energy_density,
     184             :       const gsl::not_null<Cache*> cache,
     185             :       gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 0> meta) const {
     186             :     superposition<false>(conformal_energy_density, cache, meta);
     187             :   }
     188             :   void operator()(
     189             :       const gsl::not_null<Scalar<DataType>*> conformal_stress_trace,
     190             :       const gsl::not_null<Cache*> cache,
     191             :       gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 0> meta) const {
     192             :     superposition<false>(conformal_stress_trace, cache, meta);
     193             :   }
     194             :   void operator()(
     195             :       const gsl::not_null<tnsr::I<DataType, Dim>*> conformal_momentum_density,
     196             :       const gsl::not_null<Cache*> cache,
     197             :       gr::Tags::Conformal<gr::Tags::MomentumDensity<DataType, Dim>, 0> meta)
     198             :       const {
     199             :     superposition<false>(conformal_momentum_density, cache, meta);
     200             :   }
     201             :   void operator()(
     202             :       const gsl::not_null<Scalar<DataType>*> conformal_factor_minus_one,
     203             :       const gsl::not_null<Cache*> cache,
     204             :       Tags::ConformalFactorMinusOne<DataType> meta) const {
     205             :     superposition(conformal_factor_minus_one, cache, meta);
     206             :   }
     207             :   void operator()(
     208             :       const gsl::not_null<Scalar<DataType>*>
     209             :           lapse_times_conformal_factor_minus_one,
     210             :       const gsl::not_null<Cache*> cache,
     211             :       Tags::LapseTimesConformalFactorMinusOne<DataType> meta) const {
     212             :     superposition(lapse_times_conformal_factor_minus_one, cache, meta);
     213             :   }
     214             :   void operator()(
     215             :       const gsl::not_null<tnsr::I<DataType, Dim>*> shift_excess,
     216             :       const gsl::not_null<Cache*> cache,
     217             :       Tags::ShiftExcess<DataType, Dim, Frame::Inertial> meta) const {
     218             :     superposition(shift_excess, cache, meta);
     219             :   }
     220             :   void operator()(const gsl::not_null<Scalar<DataType>*> rest_mass_density,
     221             :                   const gsl::not_null<Cache*> cache,
     222             :                   hydro::Tags::RestMassDensity<DataType> meta) const {
     223             :     superposition<false>(rest_mass_density, cache, meta);
     224             :   }
     225             :   void operator()(const gsl::not_null<Scalar<DataType>*> specific_enthalpy,
     226             :                   const gsl::not_null<Cache*> cache,
     227             :                   hydro::Tags::SpecificEnthalpy<DataType> meta) const {
     228             :     superposition<false>(specific_enthalpy, cache, meta);
     229             :   }
     230             :   void operator()(const gsl::not_null<Scalar<DataType>*> pressure,
     231             :                   const gsl::not_null<Cache*> cache,
     232             :                   hydro::Tags::Pressure<DataType> meta) const {
     233             :     superposition<false>(pressure, cache, meta);
     234             :   }
     235             :   void operator()(const gsl::not_null<tnsr::I<DataType, 3>*> spatial_velocity,
     236             :                   const gsl::not_null<Cache*> cache,
     237             :                   hydro::Tags::SpatialVelocity<DataType, 3> meta) const {
     238             :     superposition<false>(spatial_velocity, cache, meta);
     239             :   }
     240             :   void operator()(const gsl::not_null<Scalar<DataType>*> lorentz_factor,
     241             :                   const gsl::not_null<Cache*> cache,
     242             :                   hydro::Tags::LorentzFactor<DataType> meta) const {
     243             :     superposition<false>(lorentz_factor, cache, meta);
     244             :   }
     245             :   void operator()(const gsl::not_null<tnsr::I<DataType, 3>*> magnetic_field,
     246             :                   const gsl::not_null<Cache*> cache,
     247             :                   hydro::Tags::MagneticField<DataType, 3> meta) const {
     248             :     superposition<false>(magnetic_field, cache, meta);
     249             :   }
     250             : 
     251             :  private:
     252             :   void add_deriv_of_window_function(
     253             :       gsl::not_null<tnsr::ijj<DataType, Dim>*> deriv_conformal_metric) const;
     254             : };
     255             : }  // namespace detail
     256             : 
     257             : /*!
     258             :  * \brief Binary compact-object data in general relativity, constructed from
     259             :  * superpositions of two isolated objects.
     260             :  *
     261             :  * This class implements background data for the XCTS equations describing two
     262             :  * objects in a quasi-equilibrium orbit, i.e. with \f$\bar{u}=0\f$ and
     263             :  * \f$\partial_t K=0\f$. Both objects can be chosen from the list of
     264             :  * `IsolatedObjectRegistrars`, e.g. they can be black-hole or neutron-star
     265             :  * solutions in different coordinates. Most quantities are constructed by
     266             :  * superposing the two isolated solutions (see e.g. Eq. (8-9) in
     267             :  * \cite Varma2018sqd or Eq. (45-46) in \cite Lovelace2008tw):
     268             :  *
     269             :  * \f{align}
     270             :  * \bar{\gamma}_{ij} &= f_{ij} + \sum_{\alpha=1}^2
     271             :  * e^{-r_\alpha^2 / w_\alpha^2}\left(\gamma^\alpha_{ij} - f_{ij}\right) \\
     272             :  * K &= \sum_{\alpha=1}^2 e^{-r_\alpha^2 / w_\alpha^2}K^\alpha
     273             :  * \f}
     274             :  *
     275             :  * where \f$\gamma^\alpha_{ij}\f$ and \f$K^\alpha\f$ denote the spatial metric
     276             :  * and extrinsic-curvature trace of the two individual solutions, \f$r_\alpha\f$
     277             :  * is the Euclidean coordinate-distance from the center of each object and
     278             :  * \f$w_\alpha\f$ are parameters describing the falloff widths of Gaussian
     279             :  * window functions. The window functions
     280             :  * facilitate that the influence of either of the two objects
     281             :  * at the position of the other is strongly damped, and they also avoid
     282             :  * logarithmic scaling of the solution at large distances where we would
     283             :  * typically employ an inverse-radial coordinate map and asymptotically-flat
     284             :  * boundary conditions. The falloff-widths are chosen in terms of the Newtonian
     285             :  * Lagrange points of the two objects in \cite Varma2018sqd and
     286             :  * \cite Lovelace2008tw, and they are input parameters in this implementation.
     287             :  * The falloff can be disabled by passing `std::nullopt` to the constructor, or
     288             :  * `None` in the input file.
     289             :  *
     290             :  * \par Matter sources
     291             :  * Matter sources are superposed without the window functions. The analytic
     292             :  * matter sources are of
     293             :  * limited use anyway, because in a binary setting they don't take the
     294             :  * gravitational influence of the other body into account. Therefore, the matter
     295             :  * sources should typically be solved-for alongside the gravity sector to impose
     296             :  * conditions such as hydrostatic equilibrium. For scenarios where we just want
     297             :  * to superpose the isolated matter solutions and compute the resulting gravity,
     298             :  * the matter sources are simply added.
     299             :  *
     300             :  * \par Orbital motion
     301             :  * The remaining quantities that this class implements relate to the orbital
     302             :  * motion of the two objects. To obtain initial data in "co-rotating"
     303             :  * coordinates where the two objects are initially at rest we prescribe the
     304             :  * background shift
     305             :  *
     306             :  * \f{equation} \beta^i_\mathrm{background} = (-\Omega y, \Omega x, 0) +
     307             :  * \dot{a}_0 x^i + v^i_0 \f}
     308             :  *
     309             :  * where \f$\Omega\f$ is the angular-velocity parameter and \f$\dot{a}_0\f$
     310             :  * is an expansion parameter. Both control the eccentricity of the orbit.
     311             :  * The parameter \f$v^i_0\f$ is a constant velocity that can be used to
     312             :  * control the linear momentum of the system (see Eq. (28) in
     313             :  * \cite Ossokine2015yla).
     314             :  */
     315             : template <typename IsolatedObjectBase, typename IsolatedObjectClasses>
     316           1 : class Binary : public elliptic::analytic_data::Background,
     317             :                public elliptic::analytic_data::InitialGuess {
     318             :  public:
     319           0 :   struct XCoords {
     320           0 :     static constexpr Options::String help =
     321             :         "The coordinates on the x-axis where the two objects are placed";
     322           0 :     using type = std::array<double, 2>;
     323             :   };
     324           0 :   struct ObjectLeft {
     325           0 :     static constexpr Options::String help =
     326             :         "The object placed on the negative x-axis";
     327           0 :     using type = std::unique_ptr<IsolatedObjectBase>;
     328             :   };
     329           0 :   struct ObjectRight {
     330           0 :     static constexpr Options::String help =
     331             :         "The object placed on the positive x-axis";
     332           0 :     using type = std::unique_ptr<IsolatedObjectBase>;
     333             :   };
     334           0 :   struct AngularVelocity {
     335           0 :     static constexpr Options::String help =
     336             :         "Orbital angular velocity 'Omega0' about the z-axis. Added to the "
     337             :         "background shift as a term 'Omega0 x r'.";
     338           0 :     using type = double;
     339             :   };
     340           0 :   struct Expansion {
     341           0 :     static constexpr Options::String help =
     342             :         "The expansion parameter 'adot0', which is a radial velocity over "
     343             :         "radius. Added to the background shift as a term 'adot0 r^i'";
     344           0 :     using type = double;
     345             :   };
     346           0 :   struct LinearVelocity {
     347           0 :     static constexpr Options::String help =
     348             :         "Constant velocity 'v0' added to the background shift to control the "
     349             :         "linear momentum of the system.";
     350           0 :     using type = std::array<double, 3>;
     351             :   };
     352           0 :   struct FalloffWidths {
     353           0 :     static constexpr Options::String help =
     354             :         "The widths for the window functions around the two objects, or 'None' "
     355             :         "to disable the Gaussian falloff.";
     356           0 :     using type = Options::Auto<std::array<double, 2>, Options::AutoLabel::None>;
     357             :   };
     358           0 :   using options = tmpl::list<XCoords, ObjectLeft, ObjectRight, AngularVelocity,
     359             :                              Expansion, LinearVelocity, FalloffWidths>;
     360           0 :   static constexpr Options::String help =
     361             :       "Binary compact-object data in general relativity, constructed from "
     362             :       "superpositions of two isolated objects.";
     363             : 
     364           0 :   Binary() = default;
     365           0 :   Binary(const Binary&) = delete;
     366           0 :   Binary& operator=(const Binary&) = delete;
     367           0 :   Binary(Binary&&) = default;
     368           0 :   Binary& operator=(Binary&&) = default;
     369           0 :   ~Binary() = default;
     370             : 
     371           0 :   Binary(const std::array<double, 2> xcoords,
     372             :          std::unique_ptr<IsolatedObjectBase> object_left,
     373             :          std::unique_ptr<IsolatedObjectBase> object_right,
     374             :          const double angular_velocity, const double expansion,
     375             :          const std::array<double, 3> linear_velocity,
     376             :          const std::optional<std::array<double, 2>> falloff_widths,
     377             :          const Options::Context& context = {})
     378             :       : xcoords_(xcoords),
     379             :         superposed_objects_({std::move(object_left), std::move(object_right)}),
     380             :         angular_velocity_(angular_velocity),
     381             :         expansion_(expansion),
     382             :         linear_velocity_(linear_velocity),
     383             :         falloff_widths_(falloff_widths) {
     384             :     if (xcoords_[0] >= xcoords_[1]) {
     385             :       PARSE_ERROR(context, "Specify 'XCoords' ascending from left to right.");
     386             :     }
     387             :   }
     388             : 
     389           0 :   explicit Binary(CkMigrateMessage* m)
     390             :       : elliptic::analytic_data::Background(m),
     391             :         elliptic::analytic_data::InitialGuess(m) {}
     392             :   using PUP::able::register_constructor;
     393           0 :   WRAPPED_PUPable_decl_template(Binary);
     394             : 
     395             :   template <typename DataType, typename... RequestedTags>
     396           0 :   tuples::TaggedTuple<RequestedTags...> variables(
     397             :       const tnsr::I<DataType, 3, Frame::Inertial>& x,
     398             :       tmpl::list<RequestedTags...> /*meta*/) const {
     399             :     return variables_impl<DataType>(x, std::nullopt, std::nullopt,
     400             :                                     tmpl::list<RequestedTags...>{});
     401             :   }
     402             :   template <typename... RequestedTags>
     403           0 :   tuples::TaggedTuple<RequestedTags...> variables(
     404             :       const tnsr::I<DataVector, 3, Frame::Inertial>& x, const Mesh<3>& mesh,
     405             :       const InverseJacobian<DataVector, 3, Frame::ElementLogical,
     406             :                             Frame::Inertial>& inv_jacobian,
     407             :       tmpl::list<RequestedTags...> /*meta*/) const {
     408             :     return variables_impl<DataVector>(x, mesh, inv_jacobian,
     409             :                                       tmpl::list<RequestedTags...>{});
     410             :   }
     411             : 
     412             :   // NOLINTNEXTLINE
     413           0 :   void pup(PUP::er& p) override {
     414             :     elliptic::analytic_data::Background::pup(p);
     415             :     elliptic::analytic_data::InitialGuess::pup(p);
     416             :     p | xcoords_;
     417             :     p | superposed_objects_;
     418             :     p | angular_velocity_;
     419             :     p | expansion_;
     420             :     p | linear_velocity_;
     421             :     p | falloff_widths_;
     422             :   }
     423             : 
     424             :   /// Coordinates of the objects, ascending left to right
     425           1 :   const std::array<double, 2>& x_coords() const { return xcoords_; }
     426             :   /// The two objects. First entry is the left object, second entry is the right
     427             :   /// object.
     428           1 :   const std::array<std::unique_ptr<IsolatedObjectBase>, 2>& superposed_objects()
     429             :       const {
     430             :     return superposed_objects_;
     431             :   }
     432           0 :   double angular_velocity() const { return angular_velocity_; }
     433           0 :   double expansion() const { return expansion_; }
     434           0 :   const std::array<double, 3>& linear_velocity() const {
     435             :     return linear_velocity_;
     436             :   }
     437           0 :   const std::optional<std::array<double, 2>>& falloff_widths() const {
     438             :     return falloff_widths_;
     439             :   }
     440             : 
     441             :  private:
     442           0 :   std::array<double, 2> xcoords_{};
     443           0 :   std::array<std::unique_ptr<IsolatedObjectBase>, 2> superposed_objects_{};
     444           0 :   Xcts::Solutions::Flatness flatness_{};
     445           0 :   double angular_velocity_ = std::numeric_limits<double>::signaling_NaN();
     446           0 :   double expansion_ = std::numeric_limits<double>::signaling_NaN();
     447           0 :   std::array<double, 3> linear_velocity_{};
     448           0 :   std::optional<std::array<double, 2>> falloff_widths_{};
     449             : 
     450             :   template <typename DataType, typename... RequestedTags>
     451           0 :   tuples::TaggedTuple<RequestedTags...> variables_impl(
     452             :       const tnsr::I<DataType, 3, Frame::Inertial>& x,
     453             :       std::optional<std::reference_wrapper<const Mesh<3>>> mesh,
     454             :       std::optional<std::reference_wrapper<const InverseJacobian<
     455             :           DataType, 3, Frame::ElementLogical, Frame::Inertial>>>
     456             :           inv_jacobian,
     457             :       tmpl::list<RequestedTags...> /*meta*/) const {
     458             :     std::array<tnsr::I<DataVector, 3>, 2> x_isolated{{x, x}};
     459             :     std::array<DataVector, 2> euclidean_distance{};
     460             :     std::array<DataVector, 2> windows{};
     461             :     // Possible optimization: Only retrieve those superposed tags from the
     462             :     // isolated solutions that are actually needed. This needs some dependency
     463             :     // logic, because some of the non-superposed tags depend on superposed tags.
     464             :     using VarsComputer = detail::BinaryVariables<DataType>;
     465             :     using requested_superposed_tags = typename VarsComputer::superposed_tags;
     466             :     std::array<tuples::tagged_tuple_from_typelist<requested_superposed_tags>, 2>
     467             :         isolated_vars;
     468             :     for (size_t i = 0; i < 2; ++i) {
     469             :       get<0>(gsl::at(x_isolated, i)) -= gsl::at(xcoords_, i);
     470             :       gsl::at(euclidean_distance, i) = get(magnitude(gsl::at(x_isolated, i)));
     471             :       if (falloff_widths_.has_value()) {
     472             :         gsl::at(windows, i) = exp(-square(gsl::at(euclidean_distance, i)) /
     473             :                                   square(gsl::at(*falloff_widths_, i)));
     474             :       } else {
     475             :         gsl::at(windows, i) = make_with_value<DataVector>(x, 1.);
     476             :       }
     477             :       gsl::at(isolated_vars, i) = get_isolated_vars<requested_superposed_tags>(
     478             :           *gsl::at(superposed_objects_, i), gsl::at(x_isolated, i));
     479             :     }
     480             :     auto flat_vars = flatness_.variables(x, requested_superposed_tags{});
     481             :     typename VarsComputer::Cache cache{get_size(*x.begin())};
     482             :     const VarsComputer computer{std::move(mesh),
     483             :                                 std::move(inv_jacobian),
     484             :                                 x,
     485             :                                 angular_velocity_,
     486             :                                 expansion_,
     487             :                                 linear_velocity_,
     488             :                                 falloff_widths_,
     489             :                                 std::move(x_isolated),
     490             :                                 std::move(windows),
     491             :                                 std::move(flat_vars),
     492             :                                 std::move(isolated_vars)};
     493             :     return {cache.get_var(computer, RequestedTags{})...};
     494             :   }
     495             : 
     496             :   template <typename TagsList, typename... Args>
     497           0 :   tuples::tagged_tuple_from_typelist<TagsList> get_isolated_vars(
     498             :       const IsolatedObjectBase& isolated_object, const Args&... args) const {
     499             :     return call_with_dynamic_type<tuples::tagged_tuple_from_typelist<TagsList>,
     500             :                                   IsolatedObjectClasses>(
     501             :         &isolated_object, [&args...](const auto* const derived) {
     502             :           return derived->variables(args..., TagsList{});
     503             :         });
     504             :   }
     505             : };
     506             : 
     507             : /// \cond
     508             : template <typename IsolatedObjectBase, typename IsolatedObjectClasses>
     509             : PUP::able::PUP_ID Binary<IsolatedObjectBase, IsolatedObjectClasses>::my_PUP_ID =
     510             :     0;  // NOLINT
     511             : /// \endcond
     512             : 
     513             : }  // namespace Xcts::AnalyticData

Generated by: LCOV version 1.14