SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryConditions - HydroFreeOutflow.hpp Hit Total Coverage
Commit: 3c072f0ce967e2e56649d3fa12aa2a0e4fe2a42e Lines: 1 43 2.3 %
Date: 2024-04-23 20:50:18
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 hydrodynamic free outflow and no inflow boundary condition to
      39             :  * GRMHD primitive variables.
      40             :  *
      41             :  * All primitive variables at the boundary are copied into ghost zone except :
      42             :  *
      43             :  *  - If \f$n_iv^i \geq 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 normal component is zero at the interface i.e.
      47             :  * \f$v_\text{ghost}^i = v^i - (n_jv^j)n^i\f$.
      48             :  *
      49             :  *  - However, regardless of whether the normal component of the spatial
      50             :  * velocity $n_iv^i$ is pointing outward or inward, the lorentz factor \f$W\f$
      51             :  * is copied into ghost zone without any modification.
      52             :  *
      53             :  * \note In principle we need to recompute the Lorentz factor
      54             :  * \f$W_\text{ghost}\f$ using $v_\text{ghost}^i$. However, the case in which
      55             :  * skipping that procedure becomes problematic is only when the fluid has
      56             :  * relativistic incoming normal speed on the external boundary, which already
      57             :  * implies the failure of adopting outflow type boundary conditions.
      58             :  *
      59             :  *  - Divergence cleaning scalar field \f$\Phi\f$ is set to zero in ghost zone.
      60             :  *
      61             :  */
      62           1 : class HydroFreeOutflow final : public BoundaryCondition {
      63             :  private:
      64           0 :   using RestMassDensity = hydro::Tags::RestMassDensity<DataVector>;
      65           0 :   using ElectronFraction = hydro::Tags::ElectronFraction<DataVector>;
      66           0 :   using Temperature = hydro::Tags::Temperature<DataVector>;
      67           0 :   using Pressure = hydro::Tags::Pressure<DataVector>;
      68           0 :   using LorentzFactorTimesSpatialVelocity =
      69             :       hydro::Tags::LorentzFactorTimesSpatialVelocity<DataVector, 3>;
      70           0 :   using MagneticField = hydro::Tags::MagneticField<DataVector, 3>;
      71           0 :   using DivergenceCleaningField =
      72             :       hydro::Tags::DivergenceCleaningField<DataVector>;
      73           0 :   using SpecificInternalEnergy =
      74             :       hydro::Tags::SpecificInternalEnergy<DataVector>;
      75           0 :   using SpatialVelocity = hydro::Tags::SpatialVelocity<DataVector, 3>;
      76           0 :   using LorentzFactor = hydro::Tags::LorentzFactor<DataVector>;
      77           0 :   using SqrtDetSpatialMetric = gr::Tags::SqrtDetSpatialMetric<DataVector>;
      78           0 :   using SpatialMetric = gr::Tags::SpatialMetric<DataVector, 3>;
      79           0 :   using InvSpatialMetric = gr::Tags::InverseSpatialMetric<DataVector, 3>;
      80           0 :   using Lapse = gr::Tags::Lapse<DataVector>;
      81           0 :   using Shift = gr::Tags::Shift<DataVector, 3>;
      82             : 
      83           0 :   using prim_tags_for_reconstruction =
      84             :       tmpl::list<RestMassDensity, ElectronFraction, Temperature,
      85             :                  LorentzFactorTimesSpatialVelocity, MagneticField,
      86             :                  DivergenceCleaningField>;
      87             : 
      88             :   template <typename T>
      89           0 :   using Flux = ::Tags::Flux<T, tmpl::size_t<3>, Frame::Inertial>;
      90             : 
      91             :  public:
      92           0 :   using options = tmpl::list<>;
      93           0 :   static constexpr Options::String help{
      94             :       "Free outflow & no inflow boundary condition on GRMHD primitive "
      95             :       "variables"};
      96             : 
      97           0 :   HydroFreeOutflow() = default;
      98           0 :   HydroFreeOutflow(HydroFreeOutflow&&) = default;
      99           0 :   HydroFreeOutflow& operator=(HydroFreeOutflow&&) = default;
     100           0 :   HydroFreeOutflow(const HydroFreeOutflow&) = default;
     101           0 :   HydroFreeOutflow& operator=(const HydroFreeOutflow&) = default;
     102           0 :   ~HydroFreeOutflow() override = default;
     103             : 
     104           0 :   explicit HydroFreeOutflow(CkMigrateMessage* msg);
     105             : 
     106           0 :   WRAPPED_PUPable_decl_base_template(
     107             :       domain::BoundaryConditions::BoundaryCondition, HydroFreeOutflow);
     108             : 
     109           0 :   auto get_clone() const -> std::unique_ptr<
     110             :       domain::BoundaryConditions::BoundaryCondition> override;
     111             : 
     112           0 :   static constexpr evolution::BoundaryConditions::Type bc_type =
     113             :       evolution::BoundaryConditions::Type::Ghost;
     114             : 
     115           0 :   void pup(PUP::er& p) override;
     116             : 
     117           0 :   using dg_interior_evolved_variables_tags = tmpl::list<>;
     118           0 :   using dg_interior_primitive_variables_tags =
     119             :       tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
     120             :                  hydro::Tags::ElectronFraction<DataVector>,
     121             :                  hydro::Tags::SpecificInternalEnergy<DataVector>,
     122             :                  hydro::Tags::SpatialVelocity<DataVector, 3>,
     123             :                  hydro::Tags::MagneticField<DataVector, 3>,
     124             :                  hydro::Tags::LorentzFactor<DataVector>,
     125             :                  hydro::Tags::Pressure<DataVector>>;
     126           0 :   using dg_interior_temporary_tags = tmpl::list<Shift, Lapse, InvSpatialMetric>;
     127           0 :   using dg_gridless_tags = tmpl::list<>;
     128             : 
     129           0 :   static std::optional<std::string> dg_ghost(
     130             :       const gsl::not_null<Scalar<DataVector>*> tilde_d,
     131             :       const gsl::not_null<Scalar<DataVector>*> tilde_ye,
     132             :       const gsl::not_null<Scalar<DataVector>*> tilde_tau,
     133             :       const gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*> tilde_s,
     134             :       const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_b,
     135             :       const gsl::not_null<Scalar<DataVector>*> tilde_phi,
     136             : 
     137             :       const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
     138             :           tilde_d_flux,
     139             :       const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
     140             :           tilde_ye_flux,
     141             :       const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
     142             :           tilde_tau_flux,
     143             :       const gsl::not_null<tnsr::Ij<DataVector, 3, Frame::Inertial>*>
     144             :           tilde_s_flux,
     145             :       const gsl::not_null<tnsr::IJ<DataVector, 3, Frame::Inertial>*>
     146             :           tilde_b_flux,
     147             :       const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
     148             :           tilde_phi_flux,
     149             : 
     150             :       const gsl::not_null<Scalar<DataVector>*> lapse,
     151             :       const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> shift,
     152             :       const gsl::not_null<tnsr::II<DataVector, 3, Frame::Inertial>*>
     153             :           inv_spatial_metric,
     154             : 
     155             :       const std::optional<tnsr::I<DataVector, 3, Frame::Inertial>>&
     156             :       /*face_mesh_velocity*/,
     157             :       const tnsr::i<DataVector, 3, Frame::Inertial>&
     158             :           outward_directed_normal_covector,
     159             :       const tnsr::I<DataVector, 3, Frame::Inertial>&
     160             :           outward_directed_normal_vector,
     161             : 
     162             :       const Scalar<DataVector>& interior_rest_mass_density,
     163             :       const Scalar<DataVector>& interior_electron_fraction,
     164             :       const Scalar<DataVector>& interior_specific_internal_energy,
     165             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_spatial_velocity,
     166             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_magnetic_field,
     167             :       const Scalar<DataVector>& interior_lorentz_factor,
     168             :       const Scalar<DataVector>& interior_pressure,
     169             : 
     170             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_shift,
     171             :       const Scalar<DataVector>& interior_lapse,
     172             :       const tnsr::II<DataVector, 3, Frame::Inertial>&
     173             :           interior_inv_spatial_metric);
     174             : 
     175           0 :   using fd_interior_evolved_variables_tags = tmpl::list<>;
     176           0 :   using fd_interior_temporary_tags =
     177             :       tmpl::list<evolution::dg::subcell::Tags::Mesh<3>, Shift, Lapse,
     178             :                  SpatialMetric>;
     179           0 :   using fd_interior_primitive_variables_tags =
     180             :       tmpl::list<RestMassDensity, ElectronFraction, Temperature,
     181             :                  hydro::Tags::Pressure<DataVector>,
     182             :                  hydro::Tags::SpecificInternalEnergy<DataVector>,
     183             :                  hydro::Tags::LorentzFactor<DataVector>,
     184             :                  hydro::Tags::SpatialVelocity<DataVector, 3>, MagneticField>;
     185             : 
     186           0 :   using fd_gridless_tags = tmpl::list<fd::Tags::Reconstructor>;
     187             : 
     188           0 :   static void fd_ghost(
     189             :       gsl::not_null<Scalar<DataVector>*> rest_mass_density,
     190             :       gsl::not_null<Scalar<DataVector>*> electron_fraction,
     191             :       gsl::not_null<Scalar<DataVector>*> temperature,
     192             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
     193             :           lorentz_factor_times_spatial_velocity,
     194             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> magnetic_field,
     195             :       gsl::not_null<Scalar<DataVector>*> divergence_cleaning_field,
     196             : 
     197             :       gsl::not_null<std::optional<Variables<db::wrap_tags_in<
     198             :           Flux, typename grmhd::ValenciaDivClean::System::flux_variables>>>*>
     199             :           cell_centered_ghost_fluxes,
     200             : 
     201             :       const Direction<3>& direction,
     202             : 
     203             :       // interior temporary tags
     204             :       const Mesh<3>& subcell_mesh,
     205             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_shift,
     206             :       const Scalar<DataVector>& interior_lapse,
     207             :       const tnsr::ii<DataVector, 3, Frame::Inertial>& interior_spatial_metric,
     208             : 
     209             :       // interior prim vars tags
     210             :       const Scalar<DataVector>& interior_rest_mass_density,
     211             :       const Scalar<DataVector>& interior_electron_fraction,
     212             :       const Scalar<DataVector>& interior_temperature,
     213             :       const Scalar<DataVector>& interior_pressure,
     214             :       const Scalar<DataVector>& interior_specific_internal_energy,
     215             :       const Scalar<DataVector>& interior_lorentz_factor,
     216             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_spatial_velocity,
     217             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_magnetic_field,
     218             : 
     219             :       // gridless tags
     220             :       const fd::Reconstructor& reconstructor);
     221             : 
     222             :   // have an impl to make sharing code with GH+GRMHD easy
     223           0 :   static void fd_ghost_impl(
     224             :       gsl::not_null<Scalar<DataVector>*> rest_mass_density,
     225             :       gsl::not_null<Scalar<DataVector>*> electron_fraction,
     226             :       gsl::not_null<Scalar<DataVector>*> temperature,
     227             :       gsl::not_null<Scalar<DataVector>*> pressure,
     228             :       gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
     229             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
     230             :           lorentz_factor_times_spatial_velocity,
     231             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> spatial_velocity,
     232             :       gsl::not_null<Scalar<DataVector>*> lorentz_factor,
     233             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> magnetic_field,
     234             :       gsl::not_null<Scalar<DataVector>*> divergence_cleaning_field,
     235             :       gsl::not_null<tnsr::ii<DataVector, 3, Frame::Inertial>*> spatial_metric,
     236             :       gsl::not_null<tnsr::II<DataVector, 3, Frame::Inertial>*>
     237             :           inv_spatial_metric,
     238             :       gsl::not_null<Scalar<DataVector>*> sqrt_det_spatial_metric,
     239             :       gsl::not_null<Scalar<DataVector>*> lapse,
     240             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> shift,
     241             : 
     242             :       const Direction<3>& direction,
     243             : 
     244             :       // fd_interior_temporary_tags
     245             :       const Mesh<3>& subcell_mesh,
     246             : 
     247             :       // fd_interior_primitive_variables_tags
     248             :       const Scalar<DataVector>& interior_rest_mass_density,
     249             :       const Scalar<DataVector>& interior_electron_fraction,
     250             :       const Scalar<DataVector>& interior_temperature,
     251             :       const Scalar<DataVector>& interior_pressure,
     252             :       const Scalar<DataVector>& interior_specific_internal_energy,
     253             :       const Scalar<DataVector>& interior_lorentz_factor,
     254             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_spatial_velocity,
     255             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_magnetic_field,
     256             :       const tnsr::ii<DataVector, 3, Frame::Inertial>& interior_spatial_metric,
     257             :       const Scalar<DataVector>& interior_lapse,
     258             :       const tnsr::I<DataVector, 3, Frame::Inertial>& interior_shift,
     259             : 
     260             :       size_t ghost_zone_size, bool need_tags_for_fluxes);
     261             : };
     262             : }  // namespace grmhd::ValenciaDivClean::BoundaryConditions

Generated by: LCOV version 1.14