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

Generated by: LCOV version 1.14