SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/ScalarTensor/BoundaryCorrections - ProductOfCorrections.hpp Coverage Total Hit
Commit: dac4c303ea98d486a9da1d17f1555fa089a2d6a3 Lines: 2.9 % 35 1
Test Date: 2026-11-07 01:28:11
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              : 
      11              : #include "Evolution/BoundaryCorrection.hpp"
      12              : #include "Evolution/Systems/CurvedScalarWave/System.hpp"
      13              : #include "Evolution/Systems/CurvedScalarWave/Tags.hpp"
      14              : #include "Evolution/Systems/GeneralizedHarmonic/System.hpp"
      15              : #include "Evolution/Systems/ScalarTensor/Tags.hpp"
      16              : #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
      17              : #include "Options/String.hpp"
      18              : #include "Utilities/Gsl.hpp"
      19              : #include "Utilities/PrettyType.hpp"
      20              : #include "Utilities/Serialization/CharmPupable.hpp"
      21              : #include "Utilities/TMPL.hpp"
      22              : 
      23              : /// \cond
      24              : class DataVector;
      25              : /// \endcond
      26              : 
      27              : namespace ScalarTensor::BoundaryCorrections {
      28              : 
      29              : /*!
      30              :  * \brief Apply a boundary condition to the combined Generalized Harmonic (::gh)
      31              :  * and scalar field (::CurvedScalarWave) system using boundary corrections
      32              :  * defined separately.
      33              :  * \see gh::BoundaryCorrections and CurvedScalarWave::BoundaryCorrections.
      34              :  */
      35              : /// @{
      36              : template <
      37              :     typename DerivedGhCorrection, typename DerivedScalarCorrection,
      38              :     typename = typename DerivedGhCorrection::dg_package_field_tags,
      39              :     typename = typename DerivedScalarCorrection::dg_package_field_tags,
      40              :     typename = typename DerivedGhCorrection::dg_package_data_temporary_tags,
      41              :     typename = typename DerivedScalarCorrection::dg_package_data_temporary_tags,
      42              :     typename = typename DerivedGhCorrection::dg_package_data_volume_tags,
      43              :     typename = typename DerivedScalarCorrection::dg_package_data_volume_tags,
      44              :     typename = typename DerivedGhCorrection::dg_boundary_terms_volume_tags,
      45              :     typename = typename DerivedScalarCorrection::dg_boundary_terms_volume_tags>
      46            1 : class ProductOfCorrections;
      47              : 
      48              : template <typename DerivedGhCorrection, typename DerivedScalarCorrection,
      49              :           typename... GhDgPackagedFieldTags,
      50              :           typename... ScalarDgPackagedFieldTags,
      51              :           typename... GhDgPackageDataTemporaryTags,
      52              :           typename... ScalarDgPackageDataTemporaryTags,
      53              :           typename... GhDgPackageDataVolumeTags,
      54              :           typename... ScalarDgPackageDataVolumeTags,
      55              :           typename... GhDgBoundaryTermsVolumeTags,
      56              :           typename... ScalarDgBoundaryTermsVolumeTags>
      57            0 : class ProductOfCorrections<DerivedGhCorrection, DerivedScalarCorrection,
      58              :                            tmpl::list<GhDgPackagedFieldTags...>,
      59              :                            tmpl::list<ScalarDgPackagedFieldTags...>,
      60              :                            tmpl::list<GhDgPackageDataTemporaryTags...>,
      61              :                            tmpl::list<ScalarDgPackageDataTemporaryTags...>,
      62              :                            tmpl::list<GhDgPackageDataVolumeTags...>,
      63              :                            tmpl::list<ScalarDgPackageDataVolumeTags...>,
      64              :                            tmpl::list<GhDgBoundaryTermsVolumeTags...>,
      65              :                            tmpl::list<ScalarDgBoundaryTermsVolumeTags...>>
      66              :     final : public evolution::BoundaryCorrection {
      67              :  public:
      68            0 :   static constexpr size_t dim = 3;
      69            0 :   using dg_package_field_tags =
      70              :       tmpl::list<GhDgPackagedFieldTags..., ScalarDgPackagedFieldTags...>;
      71              : 
      72            0 :   using dg_package_data_temporary_tags =
      73              :       tmpl::list<GhDgPackageDataTemporaryTags...,
      74              :                  ScalarDgPackageDataTemporaryTags...>;
      75              : 
      76            0 :   using dg_package_data_primitive_tags = tmpl::list<>;
      77              : 
      78            0 :   using dg_package_data_volume_tags =
      79              :       tmpl::list<GhDgPackageDataVolumeTags...,
      80              :                  ScalarDgPackageDataVolumeTags...>;
      81              : 
      82            0 :   using dg_boundary_terms_volume_tags =
      83              :       tmpl::list<GhDgBoundaryTermsVolumeTags...,
      84              :                  ScalarDgBoundaryTermsVolumeTags...>;
      85              : 
      86            0 :   static std::string name() {
      87              :     return "Product" + pretty_type::name<DerivedGhCorrection>() + "GH" + "And" +
      88              :            pretty_type::name<DerivedScalarCorrection>() + "Scalar";
      89              :   }
      90              : 
      91            0 :   struct GhCorrection {
      92            0 :     using type = DerivedGhCorrection;
      93            0 :     static std::string name() {
      94              :       // We change the default name of the boundary correction to avoid errors
      95              :       // during option parsing
      96              :       return pretty_type::name<DerivedGhCorrection>() + "GH";
      97              :     }
      98            0 :     static constexpr Options::String help{
      99              :         "The Generalized Harmonic part of the product boundary condition"};
     100              :   };
     101            0 :   struct ScalarCorrection {
     102            0 :     using type = DerivedScalarCorrection;
     103            0 :     static std::string name() {
     104              :       // We change the default name of the boundary correction to avoid errors
     105              :       // during option parsing
     106              :       return pretty_type::name<DerivedScalarCorrection>() + "Scalar";
     107              :     }
     108            0 :     static constexpr Options::String help{
     109              :         "The scalar part of the product boundary condition"};
     110              :   };
     111              : 
     112            0 :   using options = tmpl::list<GhCorrection, ScalarCorrection>;
     113              : 
     114            0 :   static constexpr Options::String help = {
     115              :       "Direct product of a GH and CurvedScalarWave boundary correction. "
     116              :       "See the documentation for the two individual boundary corrections for "
     117              :       "further details."};
     118              : 
     119            0 :   ProductOfCorrections() = default;
     120            0 :   ProductOfCorrections(DerivedGhCorrection gh_correction,
     121              :                        DerivedScalarCorrection scalar_correction)
     122              :       : derived_gh_correction_{gh_correction},
     123              :         derived_scalar_correction_{scalar_correction} {}
     124            0 :   ProductOfCorrections(const ProductOfCorrections&) = default;
     125            0 :   ProductOfCorrections& operator=(const ProductOfCorrections&) = default;
     126            0 :   ProductOfCorrections(ProductOfCorrections&&) = default;
     127            0 :   ProductOfCorrections& operator=(ProductOfCorrections&&) = default;
     128            0 :   ~ProductOfCorrections() override = default;
     129              : 
     130              :   /// \cond
     131              :   explicit ProductOfCorrections(CkMigrateMessage* msg)
     132              :       : BoundaryCorrection(msg) {}
     133              :   using PUP::able::register_constructor;
     134              :   WRAPPED_PUPable_decl_template(ProductOfCorrections);  // NOLINT
     135              :   /// \endcond
     136            0 :   void pup(PUP::er& p) override {
     137              :     BoundaryCorrection::pup(p);
     138              :     p | derived_gh_correction_;
     139              :     p | derived_scalar_correction_;
     140              :   }
     141              : 
     142            0 :   std::unique_ptr<BoundaryCorrection> get_clone() const override {
     143              :     return std::make_unique<ProductOfCorrections>(*this);
     144              :   }
     145              : 
     146            0 :   double dg_package_data(
     147              :       const gsl::not_null<
     148              :           typename GhDgPackagedFieldTags::type*>... gh_packaged_fields,
     149              :       const gsl::not_null<
     150              :           typename ScalarDgPackagedFieldTags::type*>... scalar_packaged_fields,
     151              :       // GH variables
     152              :       const tnsr::aa<DataVector, dim, Frame::Inertial>& spacetime_metric,
     153              :       const tnsr::aa<DataVector, dim, Frame::Inertial>& pi,
     154              :       const tnsr::iaa<DataVector, dim, Frame::Inertial>& phi,
     155              :       // Scalar variables
     156              :       const Scalar<DataVector>& psi_scalar, const Scalar<DataVector>& pi_scalar,
     157              :       const tnsr::i<DataVector, dim, Frame::Inertial>& phi_scalar,
     158              :       // Temporaries
     159              :       const typename GhDgPackageDataTemporaryTags::type&... gh_temporaries,
     160              :       const typename ScalarDgPackageDataTemporaryTags::
     161              :           type&... scalar_temporaries,
     162              :       // Mesh variables
     163              :       const tnsr::i<DataVector, dim, Frame::Inertial>& normal_covector,
     164              :       const tnsr::I<DataVector, dim, Frame::Inertial>& normal_vector,
     165              :       const std::optional<tnsr::I<DataVector, dim, Frame::Inertial>>&
     166              :           mesh_velocity,
     167              :       const std::optional<Scalar<DataVector>>& normal_dot_mesh_velocity,
     168              :       // Volume quantities
     169              :       const typename GhDgPackageDataVolumeTags::type&... gh_volume_quantities,
     170              :       const typename ScalarDgPackageDataVolumeTags::
     171              :           type&... scalar_volume_quantities) const {
     172              :     const double gh_correction_result = derived_gh_correction_.dg_package_data(
     173              :         gh_packaged_fields..., spacetime_metric, pi, phi, gh_temporaries...,
     174              :         normal_covector, normal_vector, mesh_velocity, normal_dot_mesh_velocity,
     175              :         gh_volume_quantities...);
     176              : 
     177              :     const double scalar_correction_result =
     178              :         derived_scalar_correction_.dg_package_data(
     179              :             scalar_packaged_fields..., psi_scalar, pi_scalar, phi_scalar,
     180              :             scalar_temporaries..., normal_covector, normal_vector,
     181              :             mesh_velocity, normal_dot_mesh_velocity,
     182              :             scalar_volume_quantities...);
     183              :     return std::max(gh_correction_result, scalar_correction_result);
     184              :   }
     185              : 
     186            0 :   void dg_boundary_terms(
     187              :       // GH boundary corrections
     188              :       const gsl::not_null<tnsr::aa<DataVector, dim, Frame::Inertial>*>
     189              :           boundary_correction_spacetime_metric,
     190              :       const gsl::not_null<tnsr::aa<DataVector, dim, Frame::Inertial>*>
     191              :           boundary_correction_pi,
     192              :       const gsl::not_null<tnsr::iaa<DataVector, dim, Frame::Inertial>*>
     193              :           boundary_correction_phi,
     194              :       // Scalar boundary corrections
     195              :       const gsl::not_null<Scalar<DataVector>*> psi_boundary_correction_scalar,
     196              :       const gsl::not_null<Scalar<DataVector>*> pi_boundary_correction_scalar,
     197              :       const gsl::not_null<tnsr::i<DataVector, dim, Frame::Inertial>*>
     198              :           phi_boundary_correction_scalar,
     199              :       // Packaged fields
     200              :       const typename GhDgPackagedFieldTags::type&... gh_packaged_fields_int,
     201              :       const typename ScalarDgPackagedFieldTags::
     202              :           type&... scalar_packaged_fields_int,
     203              :       const typename GhDgPackagedFieldTags::type&... gh_packaged_fields_ext,
     204              :       const typename ScalarDgPackagedFieldTags::
     205              :           type&... scalar_packaged_fields_ext,
     206              :       // DG formulation
     207              :       const dg::Formulation dg_formulation) const {
     208              :     derived_gh_correction_.dg_boundary_terms(
     209              :         boundary_correction_spacetime_metric, boundary_correction_pi,
     210              :         boundary_correction_phi, gh_packaged_fields_int...,
     211              :         gh_packaged_fields_ext..., dg_formulation);
     212              : 
     213              :     derived_scalar_correction_.dg_boundary_terms(
     214              :         psi_boundary_correction_scalar, pi_boundary_correction_scalar,
     215              :         phi_boundary_correction_scalar, scalar_packaged_fields_int...,
     216              :         scalar_packaged_fields_ext..., dg_formulation);
     217              :   }
     218              : 
     219            0 :   const DerivedGhCorrection& gh_correction() const {
     220              :     return derived_gh_correction_;
     221              :   }
     222              : 
     223            0 :   const DerivedScalarCorrection& scalar_correction() const {
     224              :     return derived_scalar_correction_;
     225              :   }
     226              : 
     227              :  private:
     228            0 :   DerivedGhCorrection derived_gh_correction_;
     229            0 :   DerivedScalarCorrection derived_scalar_correction_;
     230              : };
     231              : /// @}
     232              : 
     233              : /// \cond
     234              : template <typename DerivedGhCorrection, typename DerivedScalarCorrection,
     235              :           typename... GhDgPackagedFieldTags,
     236              :           typename... ScalarDgPackagedFieldTags,
     237              :           typename... GhDgPackageDataTemporaryTags,
     238              :           typename... ScalarDgPackageDataTemporaryTags,
     239              :           typename... GhDgPackageDataVolumeTags,
     240              :           typename... ScalarDgPackageDataVolumeTags,
     241              :           typename... GhDgBoundaryTermsVolumeTags,
     242              :           typename... ScalarDgBoundaryTermsVolumeTags>
     243              : PUP::able::PUP_ID ProductOfCorrections<
     244              :     DerivedGhCorrection, DerivedScalarCorrection,
     245              :     tmpl::list<GhDgPackagedFieldTags...>,
     246              :     tmpl::list<ScalarDgPackagedFieldTags...>,
     247              :     tmpl::list<GhDgPackageDataTemporaryTags...>,
     248              :     tmpl::list<ScalarDgPackageDataTemporaryTags...>,
     249              :     tmpl::list<GhDgPackageDataVolumeTags...>,
     250              :     tmpl::list<ScalarDgPackageDataVolumeTags...>,
     251              :     tmpl::list<GhDgBoundaryTermsVolumeTags...>,
     252              :     tmpl::list<ScalarDgBoundaryTermsVolumeTags...>>::my_PUP_ID = 0;  // NOLINT
     253              : /// \endcond
     254              : }  // namespace ScalarTensor::BoundaryCorrections
        

Generated by: LCOV version 2.0-1