SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GrMhd/GhValenciaDivClean/BoundaryCorrections - ProductOfCorrections.hpp Hit Total Coverage
Commit: 058fd9f3a53606b32c6beec17aafdb5fcf4268be Lines: 1 34 2.9 %
Date: 2024-04-27 02:05:51
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 <pup.h>
       9             : 
      10             : #include "Evolution/Systems/GeneralizedHarmonic/BoundaryCorrections/Factory.hpp"
      11             : #include "Evolution/Systems/GeneralizedHarmonic/System.hpp"
      12             : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/BoundaryCorrections/BoundaryCorrection.hpp"
      13             : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Tags.hpp"
      14             : #include "Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Factory.hpp"
      15             : #include "Evolution/Systems/GrMhd/ValenciaDivClean/System.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             : namespace grmhd::GhValenciaDivClean::BoundaryCorrections {
      24             : namespace detail {
      25             : template <typename DerivedGhCorrection, typename DerivedValenciaCorrection,
      26             :           typename GhPackageFieldTagList, typename ValenciaPackageFieldTagList,
      27             :           typename GhEvolvedTagList, typename ValenciaEvolvedTags,
      28             :           typename GhFluxTagList, typename ValenciaFluxTagList,
      29             :           typename GhTempTagList, typename ValenciaTempTagList,
      30             :           typename DeduplicatedTempTags, typename GhPrimTagList,
      31             :           typename ValenicaPrimTagList, typename GhVolumeTagList,
      32             :           typename ValenciaVolumeTagList>
      33             : struct ProductOfCorrectionsImpl;
      34             : 
      35             : template <typename DerivedGhCorrection, typename DerivedValenciaCorrection,
      36             :           typename... GhPackageFieldTags, typename... ValenciaPackageFieldTags,
      37             :           typename... GhEvolvedTags, typename... ValenciaEvolvedTags,
      38             :           typename... GhFluxTags, typename... ValenciaFluxTags,
      39             :           typename... GhTempTags, typename... ValenciaTempTags,
      40             :           typename... DeduplicatedTempTags, typename... GhPrimTags,
      41             :           typename... ValenciaPrimTags, typename... GhVolumeTags,
      42             :           typename... ValenciaVolumeTags>
      43             : struct ProductOfCorrectionsImpl<
      44             :     DerivedGhCorrection, DerivedValenciaCorrection,
      45             :     tmpl::list<GhPackageFieldTags...>, tmpl::list<ValenciaPackageFieldTags...>,
      46             :     tmpl::list<GhEvolvedTags...>, tmpl::list<ValenciaEvolvedTags...>,
      47             :     tmpl::list<GhFluxTags...>, tmpl::list<ValenciaFluxTags...>,
      48             :     tmpl::list<GhTempTags...>, tmpl::list<ValenciaTempTags...>,
      49             :     tmpl::list<DeduplicatedTempTags...>, tmpl::list<GhPrimTags...>,
      50             :     tmpl::list<ValenciaPrimTags...>, tmpl::list<GhVolumeTags...>,
      51             :     tmpl::list<ValenciaVolumeTags...>> {
      52             :   static double dg_package_data(
      53             :       const gsl::not_null<
      54             :           typename GhPackageFieldTags::type*>... gh_packaged_fields,
      55             :       const gsl::not_null<
      56             :           typename ValenciaPackageFieldTags::type*>... valencia_packaged_fields,
      57             : 
      58             :       const typename GhEvolvedTags::type&... gh_variables,
      59             :       const typename ValenciaEvolvedTags::type&... valencia_variables,
      60             : 
      61             :       const typename GhFluxTags::type&... gh_fluxes,
      62             :       const typename ValenciaFluxTags::type&... valencia_fluxes,
      63             : 
      64             :       const typename DeduplicatedTempTags::type&... temporaries,
      65             : 
      66             :       const typename GhPrimTags::type&... gh_primitives,
      67             :       const typename ValenciaPrimTags::type&... valencia_primitives,
      68             : 
      69             :       const tnsr::i<DataVector, 3, Frame::Inertial>& normal_covector,
      70             :       const tnsr::I<DataVector, 3, Frame::Inertial>& normal_vector,
      71             :       const std::optional<tnsr::I<DataVector, 3, Frame::Inertial>>&
      72             :           mesh_velocity,
      73             :       const std::optional<Scalar<DataVector>>& normal_dot_mesh_velocity,
      74             : 
      75             :       const typename GhVolumeTags::type&... gh_volume_quantities,
      76             :       const typename ValenciaVolumeTags::type&... valencia_volume_quantities,
      77             : 
      78             :       const DerivedGhCorrection& gh_correction,
      79             :       const DerivedValenciaCorrection& valencia_correction) {
      80             :     tuples::TaggedTuple<
      81             :         Tags::detail::TemporaryReference<DeduplicatedTempTags>...>
      82             :         shuffle_refs{temporaries...};
      83             :     return std::max(
      84             :         gh_correction.dg_package_data(
      85             :             gh_packaged_fields..., gh_variables..., gh_fluxes...,
      86             :             tuples::get<Tags::detail::TemporaryReference<GhTempTags>>(
      87             :                 shuffle_refs)...,
      88             :             gh_primitives..., normal_covector, normal_vector, mesh_velocity,
      89             :             normal_dot_mesh_velocity, gh_volume_quantities...),
      90             :         valencia_correction.dg_package_data(
      91             :             valencia_packaged_fields..., valencia_variables...,
      92             :             valencia_fluxes...,
      93             :             tuples::get<Tags::detail::TemporaryReference<ValenciaTempTags>>(
      94             :                 shuffle_refs)...,
      95             :             valencia_primitives..., normal_covector, normal_vector,
      96             :             mesh_velocity, normal_dot_mesh_velocity,
      97             :             valencia_volume_quantities...));
      98             :   }
      99             : 
     100             :   static void dg_boundary_terms(
     101             :       const gsl::not_null<
     102             :           typename GhEvolvedTags::type*>... gh_boundary_corrections,
     103             :       const gsl::not_null<
     104             :           typename ValenciaEvolvedTags::type*>... valencia_boundary_corrections,
     105             : 
     106             :       const typename GhPackageFieldTags::type&... gh_internal_packaged_fields,
     107             :       const typename ValenciaPackageFieldTags::
     108             :           type&... valencia_internal_packaged_fields,
     109             : 
     110             :       const typename GhPackageFieldTags::type&... gh_external_packaged_fields,
     111             :       const typename ValenciaPackageFieldTags::
     112             :           type&... valencia_external_packaged_fields,
     113             :       const dg::Formulation dg_formulation,
     114             : 
     115             :       const DerivedGhCorrection& gh_correction,
     116             :       const DerivedValenciaCorrection& valencia_correction) {
     117             :     gh_correction.dg_boundary_terms(
     118             :         gh_boundary_corrections..., gh_internal_packaged_fields...,
     119             :         gh_external_packaged_fields..., dg_formulation);
     120             :     valencia_correction.dg_boundary_terms(
     121             :         valencia_boundary_corrections..., valencia_internal_packaged_fields...,
     122             :         valencia_external_packaged_fields..., dg_formulation);
     123             :   }
     124             : };
     125             : }  // namespace detail
     126             : 
     127             : /*!
     128             :  * \brief Apply a boundary condition to the combined Generalized Harmonic (GH)
     129             :  * and Valencia GRMHD system using boundary corrections defined separately for
     130             :  * the GH and Valencia systems.
     131             :  *
     132             :  * \details The implementation of this boundary correction applies the
     133             :  * `DerivedGhCorrection` followed by the `DerivedValenciaCorrection`. It is
     134             :  * anticipated that the systems are sufficiently independent that the order of
     135             :  * application is inconsequential.
     136             :  */
     137             : template <typename DerivedGhCorrection, typename DerivedValenciaCorrection>
     138           1 : class ProductOfCorrections final : public BoundaryCorrection {
     139             :  public:
     140           0 :   using dg_package_field_tags =
     141             :       tmpl::append<typename DerivedGhCorrection::dg_package_field_tags,
     142             :                    typename DerivedValenciaCorrection::dg_package_field_tags>;
     143             : 
     144           0 :   using dg_package_data_temporary_tags = tmpl::remove_duplicates<tmpl::append<
     145             :       typename DerivedGhCorrection::dg_package_data_temporary_tags,
     146             :       typename DerivedValenciaCorrection::dg_package_data_temporary_tags>>;
     147             : 
     148           0 :   using dg_package_data_primitive_tags =
     149             :       typename DerivedValenciaCorrection::dg_package_data_primitive_tags;
     150             : 
     151           0 :   using dg_package_data_volume_tags = tmpl::append<
     152             :       typename DerivedGhCorrection::dg_package_data_volume_tags,
     153             :       typename DerivedValenciaCorrection::dg_package_data_volume_tags>;
     154             : 
     155           0 :   using dg_boundary_terms_volume_tags = tmpl::append<
     156             :       typename DerivedGhCorrection::dg_boundary_terms_volume_tags,
     157             :       typename DerivedValenciaCorrection::dg_boundary_terms_volume_tags>;
     158             : 
     159           0 :   using derived_product_correction_impl = detail::ProductOfCorrectionsImpl<
     160             :       DerivedGhCorrection, DerivedValenciaCorrection,
     161             :       typename DerivedGhCorrection::dg_package_field_tags,
     162             :       typename DerivedValenciaCorrection::dg_package_field_tags,
     163             :       typename gh::System<3_st>::variables_tag::tags_list,
     164             :       typename grmhd::ValenciaDivClean::System::variables_tag::tags_list,
     165             :       db::wrap_tags_in<::Tags::Flux, typename gh::System<3_st>::flux_variables,
     166             :                        tmpl::size_t<3_st>, Frame::Inertial>,
     167             :       db::wrap_tags_in<::Tags::Flux,
     168             :                        typename grmhd::ValenciaDivClean::System::flux_variables,
     169             :                        tmpl::size_t<3_st>, Frame::Inertial>,
     170             :       typename DerivedGhCorrection::dg_package_data_temporary_tags,
     171             :       typename DerivedValenciaCorrection::dg_package_data_temporary_tags,
     172             :       dg_package_data_temporary_tags, tmpl::list<>,
     173             :       typename DerivedValenciaCorrection::dg_package_data_primitive_tags,
     174             :       typename DerivedGhCorrection::dg_package_data_volume_tags,
     175             :       typename DerivedValenciaCorrection::dg_package_data_volume_tags>;
     176             : 
     177           0 :   static std::string name() {
     178             :     return "Product" + pretty_type::name<DerivedGhCorrection>() + "And" +
     179             :            pretty_type::name<DerivedValenciaCorrection>();
     180             :   }
     181             : 
     182           0 :   struct GhCorrection {
     183           0 :     using type = DerivedGhCorrection;
     184           0 :     static std::string name() {
     185             :       return pretty_type::name<DerivedGhCorrection>();
     186             :     }
     187           0 :     static constexpr Options::String help{
     188             :         "The Generalized Harmonic part of the product boundary condition"};
     189             :   };
     190           0 :   struct ValenciaCorrection {
     191           0 :     using type = DerivedValenciaCorrection;
     192           0 :     static std::string name() {
     193             :       return pretty_type::name<DerivedValenciaCorrection>();
     194             :     }
     195           0 :     static constexpr Options::String help{
     196             :         "The Valencia part of the product boundary condition"};
     197             :   };
     198             : 
     199           0 :   using options = tmpl::list<GhCorrection, ValenciaCorrection>;
     200             : 
     201           0 :   static constexpr Options::String help = {
     202             :       "Direct product of a GH and ValenciaDivClean GRMHD boundary correction. "
     203             :       "See the documentation for the two individual boundary corrections for "
     204             :       "further details."};
     205             : 
     206           0 :   ProductOfCorrections() = default;
     207           0 :   ProductOfCorrections(DerivedGhCorrection gh_correction,
     208             :                        DerivedValenciaCorrection valencia_correction)
     209             :       : derived_gh_correction_{gh_correction},
     210             :         derived_valencia_correction_{valencia_correction} {}
     211           0 :   ProductOfCorrections(const ProductOfCorrections&) = default;
     212           0 :   ProductOfCorrections& operator=(const ProductOfCorrections&) = default;
     213           0 :   ProductOfCorrections(ProductOfCorrections&&) = default;
     214           0 :   ProductOfCorrections& operator=(ProductOfCorrections&&) = default;
     215           0 :   ~ProductOfCorrections() override = default;
     216             : 
     217             :   /// \cond
     218             :   explicit ProductOfCorrections(CkMigrateMessage* msg)
     219             :       : BoundaryCorrection(msg) {}
     220             :   using PUP::able::register_constructor;
     221             :   WRAPPED_PUPable_decl_template(ProductOfCorrections);  // NOLINT
     222             :   /// \endcond
     223           0 :   void pup(PUP::er& p) override {
     224             :     BoundaryCorrection::pup(p);
     225             :     p | derived_gh_correction_;
     226             :     p | derived_valencia_correction_;
     227             :   }
     228             : 
     229           0 :   std::unique_ptr<BoundaryCorrection> get_clone() const override {
     230             :     return std::make_unique<ProductOfCorrections>(*this);
     231             :   }
     232             : 
     233             :   template <typename... Args>
     234           0 :   double dg_package_data(Args&&... args) const {
     235             :     return derived_product_correction_impl::dg_package_data(
     236             :         std::forward<Args>(args)..., derived_gh_correction_,
     237             :         derived_valencia_correction_);
     238             :   }
     239             : 
     240             :   template <typename... Args>
     241           0 :   void dg_boundary_terms(Args&&... args) const {
     242             :     derived_product_correction_impl::dg_boundary_terms(
     243             :         std::forward<Args>(args)..., derived_gh_correction_,
     244             :         derived_valencia_correction_);
     245             :   }
     246             : 
     247           0 :   const DerivedGhCorrection& gh_correction() const {
     248             :     return derived_gh_correction_;
     249             :   }
     250             : 
     251           0 :   const DerivedValenciaCorrection& valencia_correction() const {
     252             :     return derived_valencia_correction_;
     253             :   }
     254             : 
     255             :  private:
     256           0 :   DerivedGhCorrection derived_gh_correction_;
     257           0 :   DerivedValenciaCorrection derived_valencia_correction_;
     258             : };
     259             : 
     260             : /// \cond
     261             : template <typename DerivedGhCorrection, typename DerivedValenciaCorrection>
     262             : PUP::able::PUP_ID ProductOfCorrections<DerivedGhCorrection,
     263             :                                        DerivedValenciaCorrection>::my_PUP_ID =
     264             :     0;  // NOLINT
     265             : /// \endcond
     266             : }  // namespace grmhd::GhValenciaDivClean::BoundaryCorrections

Generated by: LCOV version 1.14