SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GrMhd/GhValenciaDivClean/BoundaryCorrections - ProductOfCorrections.hpp Hit Total Coverage
Commit: 0774c42281e2dd78eb3afd28e00bd1e697e8ec2c Lines: 1 31 3.2 %
Date: 2022-09-26 23:02:29
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/Options.hpp"
      18             : #include "Parallel/CharmPupable.hpp"
      19             : #include "Utilities/Gsl.hpp"
      20             : #include "Utilities/PrettyType.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 derived_product_correction_impl = detail::ProductOfCorrectionsImpl<
     156             :       DerivedGhCorrection, DerivedValenciaCorrection,
     157             :       typename DerivedGhCorrection::dg_package_field_tags,
     158             :       typename DerivedValenciaCorrection::dg_package_field_tags,
     159             :       typename GeneralizedHarmonic::System<3_st>::variables_tag::tags_list,
     160             :       typename grmhd::ValenciaDivClean::System::variables_tag::tags_list,
     161             :       db::wrap_tags_in<
     162             :           ::Tags::Flux,
     163             :           typename GeneralizedHarmonic::System<3_st>::flux_variables,
     164             :           tmpl::size_t<3_st>, Frame::Inertial>,
     165             :       db::wrap_tags_in<::Tags::Flux,
     166             :                        typename grmhd::ValenciaDivClean::System::flux_variables,
     167             :                        tmpl::size_t<3_st>, Frame::Inertial>,
     168             :       typename DerivedGhCorrection::dg_package_data_temporary_tags,
     169             :       typename DerivedValenciaCorrection::dg_package_data_temporary_tags,
     170             :       dg_package_data_temporary_tags, tmpl::list<>,
     171             :       typename DerivedValenciaCorrection::dg_package_data_primitive_tags,
     172             :       typename DerivedGhCorrection::dg_package_data_volume_tags,
     173             :       typename DerivedValenciaCorrection::dg_package_data_volume_tags>;
     174             : 
     175           0 :   static std::string name() {
     176             :     return "Product" + pretty_type::name<DerivedGhCorrection>() + "And" +
     177             :            pretty_type::name<DerivedValenciaCorrection>();
     178             :   }
     179             : 
     180           0 :   struct GhCorrection {
     181           0 :     using type = DerivedGhCorrection;
     182           0 :     static std::string name() {
     183             :       return pretty_type::name<DerivedGhCorrection>();
     184             :     }
     185           0 :     static constexpr Options::String help{
     186             :         "The Generalized Harmonic part of the product boundary condition"};
     187             :   };
     188           0 :   struct ValenciaCorrection {
     189           0 :     using type = DerivedValenciaCorrection;
     190           0 :     static std::string name() {
     191             :       return pretty_type::name<DerivedValenciaCorrection>();
     192             :     }
     193           0 :     static constexpr Options::String help{
     194             :         "The Valencia part of the product boundary condition"};
     195             :   };
     196             : 
     197           0 :   using options = tmpl::list<GhCorrection, ValenciaCorrection>;
     198             : 
     199           0 :   static constexpr Options::String help = {
     200             :       "Direct product of a GH and ValenciaDivClean GRMHD boundary correction. "
     201             :       "See the documentation for the two individual boundary corrections for "
     202             :       "further details."};
     203             : 
     204           0 :   ProductOfCorrections() = default;
     205           0 :   ProductOfCorrections(DerivedGhCorrection gh_correction,
     206             :                        DerivedValenciaCorrection valencia_correction)
     207             :       : derived_gh_correction_{gh_correction},
     208             :         derived_valencia_correction_{valencia_correction} {}
     209           0 :   ProductOfCorrections(const ProductOfCorrections&) = default;
     210           0 :   ProductOfCorrections& operator=(const ProductOfCorrections&) = default;
     211           0 :   ProductOfCorrections(ProductOfCorrections&&) = default;
     212           0 :   ProductOfCorrections& operator=(ProductOfCorrections&&) = default;
     213           0 :   ~ProductOfCorrections() override = default;
     214             : 
     215             :   /// \cond
     216             :   explicit ProductOfCorrections(CkMigrateMessage* msg)
     217             :       : BoundaryCorrection(msg) {}
     218             :   using PUP::able::register_constructor;
     219             :   WRAPPED_PUPable_decl_template(ProductOfCorrections);  // NOLINT
     220             :   /// \endcond
     221           0 :   void pup(PUP::er& p) override {
     222             :     p | derived_gh_correction_;
     223             :     p | derived_valencia_correction_;
     224             :     BoundaryCorrection::pup(p);
     225             :   }
     226             : 
     227           0 :   std::unique_ptr<BoundaryCorrection> get_clone() const override {
     228             :     return std::make_unique<ProductOfCorrections>(*this);
     229             :   }
     230             : 
     231             :   template <typename... Args>
     232           0 :   double dg_package_data(Args&&... args) const {
     233             :     return derived_product_correction_impl::dg_package_data(
     234             :         std::forward<Args>(args)..., derived_gh_correction_,
     235             :         derived_valencia_correction_);
     236             :   }
     237             : 
     238             :   template <typename... Args>
     239           0 :   void dg_boundary_terms(Args&&... args) const {
     240             :     derived_product_correction_impl::dg_boundary_terms(
     241             :         std::forward<Args>(args)..., derived_gh_correction_,
     242             :         derived_valencia_correction_);
     243             :   }
     244             : 
     245             :  private:
     246           0 :   DerivedGhCorrection derived_gh_correction_;
     247           0 :   DerivedValenciaCorrection derived_valencia_correction_;
     248             : };
     249             : 
     250             : /// \cond
     251             : template <typename DerivedGhCorrection, typename DerivedValenciaCorrection>
     252             : PUP::able::PUP_ID ProductOfCorrections<DerivedGhCorrection,
     253             :                                        DerivedValenciaCorrection>::my_PUP_ID =
     254             :     0;  // NOLINT
     255             : /// \endcond
     256             : }  // namespace grmhd::GhValenciaDivClean::BoundaryCorrections

Generated by: LCOV version 1.14