SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryConditions - Reflective.hpp Hit Total Coverage
Commit: 8f6d7ed2ad592dd78354983fd8e5ec2be7abb468 Lines: 1 48 2.1 %
Date: 2024-05-02 15:57:06
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 <memory>
       7             : #include <optional>
       8             : #include <pup.h>
       9             : #include <string>
      10             : 
      11             : #include "DataStructures/DataBox/PrefixHelpers.hpp"
      12             : #include "DataStructures/DataBox/Prefixes.hpp"
      13             : #include "DataStructures/Tensor/TypeAliases.hpp"
      14             : #include "Domain/BoundaryConditions/BoundaryCondition.hpp"
      15             : #include "Evolution/BoundaryConditions/Type.hpp"
      16             : #include "Evolution/DgSubcell/Tags/Mesh.hpp"
      17             : #include "Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryConditions/BoundaryCondition.hpp"
      18             : #include "Evolution/Systems/GrMhd/ValenciaDivClean/FiniteDifference/Tag.hpp"
      19             : #include "Evolution/Systems/GrMhd/ValenciaDivClean/System.hpp"
      20             : #include "Options/String.hpp"
      21             : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      22             : #include "PointwiseFunctions/Hydro/Tags.hpp"
      23             : #include "PointwiseFunctions/Hydro/Temperature.hpp"
      24             : #include "Utilities/TMPL.hpp"
      25             : 
      26             : /// \cond
      27             : class DataVector;
      28             : template <size_t VolumeDim>
      29             : class Direction;
      30             : namespace gsl {
      31             : template <typename T>
      32             : class not_null;
      33             : }  // namespace gsl
      34             : /// \endcond
      35             : 
      36             : namespace grmhd::ValenciaDivClean::BoundaryConditions {
      37             : /*!
      38             :  * \brief Apply "soft" reflective boundary condition as described in
      39             :  * \cite Shiokawa2011ih.
      40             :  *
      41             :  * All primitive variables at the boundary are copied into ghost zone except :
      42             :  *
      43             :  *  - If \f$n_iv^i \leq 0\f$ where \f$v^i\f$ is spatial velocity and \f$n_i\f$
      44             :  * is outward directed normal covector, copy the values of \f$v^i\f$ at the
      45             :  * boundary to ghost zone. If \f$n_iv^i>0\f$, spatial velocity in the ghost zone
      46             :  * is modified such that the sign of normal component is inverted at the
      47             :  * interface i.e. \f$v_\text{ghost}^i = v^i - 2*(n_jv^j)n^i\f$.
      48             :  *
      49             :  *  - If \f$n_iB^i \leq 0\f$ where \f$B^i\f$ is magnetic field and \f$n_i\f$
      50             :  * is outward directed normal covector, copy the values of \f$B^i\f$ at the
      51             :  * boundary to ghost zone. If \f$n_iB^i>0\f$, magnetic field in the ghost zone
      52             :  * is modified such that the sign of normal component is inverted at the
      53             :  * interface i.e. \f$B_\text{ghost}^i = B^i - 2*(n_jB^j)n^i\f$.
      54             :  *
      55             :  *  - If reflect_both is true, then spatial velocity and magnetic field are
      56             :  * are inverted regardless of whether the normal component is pointing outward
      57             :  * or inward.
      58             :  *
      59             :  *  - However, regardless of whether the normal component of the spatial
      60             :  * velocity $n_iv^i$ is pointing outward or inward, the lorentz factor \f$W\f$
      61             :  * is copied into ghost zone without any modification.
      62             :  *
      63             :  *  - Divergence cleaning scalar field \f$\Phi\f$ is set to zero in ghost zone.
      64             :  *
      65             :  */
      66           1 : class Reflective final : public BoundaryCondition {
      67             :  private:
      68           0 :   bool reflect_both_{false};
      69             : 
      70           0 :   using RestMassDensity = hydro::Tags::RestMassDensity<DataVector>;
      71           0 :   using ElectronFraction = hydro::Tags::ElectronFraction<DataVector>;
      72           0 :   using Temperature = hydro::Tags::Temperature<DataVector>;
      73           0 :   using Pressure = hydro::Tags::Pressure<DataVector>;
      74           0 :   using LorentzFactorTimesSpatialVelocity =
      75             :       hydro::Tags::LorentzFactorTimesSpatialVelocity<DataVector, 3>;
      76           0 :   using MagneticField = hydro::Tags::MagneticField<DataVector, 3>;
      77           0 :   using DivergenceCleaningField =
      78             :       hydro::Tags::DivergenceCleaningField<DataVector>;
      79           0 :   using SpecificInternalEnergy =
      80             :       hydro::Tags::SpecificInternalEnergy<DataVector>;
      81           0 :   using SpatialVelocity = hydro::Tags::SpatialVelocity<DataVector, 3>;
      82           0 :   using LorentzFactor = hydro::Tags::LorentzFactor<DataVector>;
      83           0 :   using SqrtDetSpatialMetric = gr::Tags::SqrtDetSpatialMetric<DataVector>;
      84           0 :   using SpatialMetric = gr::Tags::SpatialMetric<DataVector, 3>;
      85           0 :   using InvSpatialMetric = gr::Tags::InverseSpatialMetric<DataVector, 3>;
      86           0 :   using Lapse = gr::Tags::Lapse<DataVector>;
      87           0 :   using Shift = gr::Tags::Shift<DataVector, 3>;
      88             : 
      89           0 :   using prim_tags_for_reconstruction =
      90             :       tmpl::list<RestMassDensity, ElectronFraction, Temperature,
      91             :                  LorentzFactorTimesSpatialVelocity, MagneticField,
      92             :                  DivergenceCleaningField>;
      93             : 
      94             :   template <typename T>
      95           0 :   using Flux = ::Tags::Flux<T, tmpl::size_t<3>, Frame::Inertial>;
      96             : 
      97             :  public:
      98           0 :   struct ReflectBoth {
      99           0 :     using type = bool;
     100           0 :     static constexpr Options::String help = {
     101             :         "Reflect both outgoing and incoming normal component of "
     102             :         "spatial velocity and magnetic field."};
     103             :   };
     104           0 :   using options = tmpl::list<ReflectBoth>;
     105           0 :   static constexpr Options::String help{
     106             :       "Reflective boundary conditions, inverting the sign "
     107             :       "of outgoing normal component of spatial velocity "
     108             :       "and magnetic field."};
     109             : 
     110           0 :   Reflective() = default;
     111           0 :   Reflective(Reflective&&) = default;
     112           0 :   Reflective& operator=(Reflective&&) = default;
     113           0 :   Reflective(const Reflective&) = default;
     114           0 :   Reflective& operator=(const Reflective&) = default;
     115           0 :   ~Reflective() override = default;
     116             : 
     117           0 :   explicit Reflective(bool reflect_both);
     118             : 
     119           0 :   explicit Reflective(CkMigrateMessage* msg);
     120             : 
     121           0 :   WRAPPED_PUPable_decl_base_template(
     122             :       domain::BoundaryConditions::BoundaryCondition, Reflective);
     123             : 
     124           0 :   auto get_clone() const -> std::unique_ptr<
     125             :       domain::BoundaryConditions::BoundaryCondition> override;
     126             : 
     127           0 :   static constexpr evolution::BoundaryConditions::Type bc_type =
     128             :       evolution::BoundaryConditions::Type::Ghost;
     129             : 
     130           0 :   void pup(PUP::er& p) override;
     131             : 
     132           0 :   using dg_interior_evolved_variables_tags = tmpl::list<>;
     133           0 :   using dg_interior_primitive_variables_tags =
     134             :       tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
     135             :                  hydro::Tags::ElectronFraction<DataVector>,
     136             :                  hydro::Tags::SpecificInternalEnergy<DataVector>,
     137             :                  hydro::Tags::SpatialVelocity<DataVector, 3>,
     138             :                  hydro::Tags::MagneticField<DataVector, 3>,
     139             :                  hydro::Tags::LorentzFactor<DataVector>,
     140             :                  hydro::Tags::Pressure<DataVector>>;
     141           0 :   using dg_interior_temporary_tags = tmpl::list<Shift, Lapse, InvSpatialMetric>;
     142           0 :   using dg_gridless_tags = tmpl::list<>;
     143             : 
     144           0 :   std::optional<std::string> dg_ghost(
     145             :       gsl::not_null<Scalar<DataVector>*> tilde_d,
     146             :       gsl::not_null<Scalar<DataVector>*> tilde_ye,
     147             :       gsl::not_null<Scalar<DataVector>*> tilde_tau,
     148             :       gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*> tilde_s,
     149             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_b,
     150             :       gsl::not_null<Scalar<DataVector>*> tilde_phi,
     151             : 
     152             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_d_flux,
     153             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_ye_flux,
     154             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_tau_flux,
     155             :       gsl::not_null<tnsr::Ij<DataVector, 3, Frame::Inertial>*> tilde_s_flux,
     156             :       gsl::not_null<tnsr::IJ<DataVector, 3, Frame::Inertial>*> tilde_b_flux,
     157             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_phi_flux,
     158             : 
     159             :       gsl::not_null<Scalar<DataVector>*> lapse,
     160             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> shift,
     161             :       gsl::not_null<tnsr::II<DataVector, 3, Frame::Inertial>*>
     162             :           inv_spatial_metric,
     163             : 
     164             :       const std::optional<tnsr::I<DataVector, 3, Frame::Inertial>>&
     165             :       /*face_mesh_velocity*/,
     166             :       const tnsr::i<DataVector, 3, Frame::Inertial>&
     167             :           outward_directed_normal_covector,
     168             :       const tnsr::I<DataVector, 3, Frame::Inertial>&
     169             :           outward_directed_normal_vector,
     170             : 
     171             :       const Scalar<DataVector>& interior_rest_mass_density,
     172             :       const Scalar<DataVector>& interior_electron_fraction,
     173             :       const Scalar<DataVector>& interior_specific_internal_energy,
     174             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_spatial_velocity,
     175             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_magnetic_field,
     176             :       const Scalar<DataVector>& interior_lorentz_factor,
     177             :       const Scalar<DataVector>& interior_pressure,
     178             : 
     179             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_shift,
     180             :       const Scalar<DataVector>& interior_lapse,
     181             :       const tnsr::II<DataVector, 3, Frame::Inertial>&
     182             :           interior_inv_spatial_metric) const;
     183             : 
     184           0 :   using fd_interior_evolved_variables_tags = tmpl::list<>;
     185           0 :   using fd_interior_temporary_tags =
     186             :       tmpl::list<evolution::dg::subcell::Tags::Mesh<3>, Shift, Lapse,
     187             :                  SpatialMetric>;
     188           0 :   using fd_interior_primitive_variables_tags =
     189             :       tmpl::list<RestMassDensity, ElectronFraction, Temperature,
     190             :                  hydro::Tags::Pressure<DataVector>,
     191             :                  hydro::Tags::SpecificInternalEnergy<DataVector>,
     192             :                  hydro::Tags::LorentzFactor<DataVector>,
     193             :                  hydro::Tags::SpatialVelocity<DataVector, 3>, MagneticField>;
     194             : 
     195           0 :   using fd_gridless_tags = tmpl::list<fd::Tags::Reconstructor>;
     196             : 
     197           0 :   void fd_ghost(
     198             :       gsl::not_null<Scalar<DataVector>*> rest_mass_density,
     199             :       gsl::not_null<Scalar<DataVector>*> electron_fraction,
     200             :       gsl::not_null<Scalar<DataVector>*> temperature,
     201             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
     202             :           lorentz_factor_times_spatial_velocity,
     203             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> magnetic_field,
     204             :       gsl::not_null<Scalar<DataVector>*> divergence_cleaning_field,
     205             : 
     206             :       gsl::not_null<std::optional<Variables<db::wrap_tags_in<
     207             :           Flux, typename grmhd::ValenciaDivClean::System::flux_variables>>>*>
     208             :           cell_centered_ghost_fluxes,
     209             : 
     210             :       const Direction<3>& direction,
     211             : 
     212             :       // interior temporary tags
     213             :       const Mesh<3>& subcell_mesh,
     214             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_shift,
     215             :       const Scalar<DataVector>& interior_lapse,
     216             :       const tnsr::ii<DataVector, 3, Frame::Inertial>& interior_spatial_metric,
     217             : 
     218             :       // interior prim vars tags
     219             :       const Scalar<DataVector>& interior_rest_mass_density,
     220             :       const Scalar<DataVector>& interior_electron_fraction,
     221             :       const Scalar<DataVector>& interior_temperature,
     222             :       const Scalar<DataVector>& interior_pressure,
     223             :       const Scalar<DataVector>& interior_specific_internal_energy,
     224             :       const Scalar<DataVector>& interior_lorentz_factor,
     225             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_spatial_velocity,
     226             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_magnetic_field,
     227             : 
     228             :       // gridless tags
     229             :       const fd::Reconstructor& reconstructor) const;
     230             : 
     231             :   // have an impl to make sharing code with GH+GRMHD easy
     232           0 :   void fd_ghost_impl(
     233             :       gsl::not_null<Scalar<DataVector>*> rest_mass_density,
     234             :       gsl::not_null<Scalar<DataVector>*> electron_fraction,
     235             :       gsl::not_null<Scalar<DataVector>*> temperature,
     236             :       gsl::not_null<Scalar<DataVector>*> pressure,
     237             :       gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
     238             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
     239             :           lorentz_factor_times_spatial_velocity,
     240             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> spatial_velocity,
     241             :       gsl::not_null<Scalar<DataVector>*> lorentz_factor,
     242             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> magnetic_field,
     243             :       gsl::not_null<Scalar<DataVector>*> divergence_cleaning_field,
     244             :       gsl::not_null<tnsr::ii<DataVector, 3, Frame::Inertial>*> spatial_metric,
     245             :       gsl::not_null<tnsr::II<DataVector, 3, Frame::Inertial>*>
     246             :           inv_spatial_metric,
     247             :       gsl::not_null<Scalar<DataVector>*> sqrt_det_spatial_metric,
     248             :       gsl::not_null<Scalar<DataVector>*> lapse,
     249             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> shift,
     250             : 
     251             :       const Direction<3>& direction,
     252             : 
     253             :       // fd_interior_temporary_tags
     254             :       const Mesh<3>& subcell_mesh,
     255             : 
     256             :       // fd_interior_primitive_variables_tags
     257             :       const Scalar<DataVector>& interior_rest_mass_density,
     258             :       const Scalar<DataVector>& interior_electron_fraction,
     259             :       const Scalar<DataVector>& interior_temperature,
     260             :       const Scalar<DataVector>& interior_pressure,
     261             :       const Scalar<DataVector>& interior_specific_internal_energy,
     262             :       const Scalar<DataVector>& interior_lorentz_factor,
     263             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_spatial_velocity,
     264             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_magnetic_field,
     265             :       const tnsr::ii<DataVector, 3, Frame::Inertial>& interior_spatial_metric,
     266             :       const Scalar<DataVector>& interior_lapse,
     267             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_shift,
     268             : 
     269             :       size_t ghost_zone_size, bool need_tags_for_fluxes) const;
     270             :   };
     271             : }  // namespace grmhd::ValenciaDivClean::BoundaryConditions

Generated by: LCOV version 1.14