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 : 9 : #include "DataStructures/DataBox/Prefixes.hpp" 10 : #include "DataStructures/Tensor/TypeAliases.hpp" 11 : #include "Evolution/Systems/Burgers/BoundaryCorrections/BoundaryCorrection.hpp" 12 : #include "Evolution/Systems/Burgers/Tags.hpp" 13 : #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp" 14 : #include "Options/String.hpp" 15 : #include "Utilities/Serialization/CharmPupable.hpp" 16 : #include "Utilities/TMPL.hpp" 17 : 18 : /// \cond 19 : class DataVector; 20 : namespace gsl { 21 : template <typename T> 22 : class not_null; 23 : } // namespace gsl 24 : namespace PUP { 25 : class er; 26 : } // namespace PUP 27 : /// \endcond 28 : 29 : namespace Burgers::BoundaryCorrections { 30 : /*! 31 : * \brief An HLL (Harten-Lax-van Leer) Riemann solver 32 : * 33 : * Let \f$U\f$ be the evolved variable, \f$F^i\f$ the flux, and \f$n_i\f$ be 34 : * the outward directed unit normal to the interface. Denoting \f$F := n_i 35 : * F^i\f$, the HLL boundary correction is \cite Harten1983 36 : * 37 : * \f{align*} 38 : * G_\text{HLL} = \frac{\lambda_\text{max} F_\text{int} + 39 : * \lambda_\text{min} F_\text{ext}}{\lambda_\text{max} - \lambda_\text{min}} 40 : * - \frac{\lambda_\text{min}\lambda_\text{max}}{\lambda_\text{max} - 41 : * \lambda_\text{min}} \left(U_\text{int} - U_\text{ext}\right) 42 : * \f} 43 : * 44 : * where "int" and "ext" stand for interior and exterior, and \cite Davis1988 45 : * 46 : * \f{align*} 47 : * \lambda_\text{min} &= \text{min}\left(U_\text{int},-U_\text{ext}, 0\right) \\ 48 : * \lambda_\text{max} &= \text{max}\left(U_\text{int},-U_\text{ext}, 0\right), 49 : * \f} 50 : * 51 : * The positive sign in front of the \f$F_{\text{ext}}\f$ in \f$G_\text{HLL}\f$ 52 : * and the minus signs in front of the \f$U_\text{ext}\f$ terms in 53 : * \f$\lambda_\text{min}\f$ and \f$\lambda_\text{max}\f$ terms are necessary 54 : * because the outward directed normal of the neighboring element has the 55 : * opposite sign, i.e. \f$n_i^{\text{ext}}=-n_i^{\text{int}}\f$. Note that for 56 : * either \f$\lambda_\text{min} = 0\f$ or \f$\lambda_\text{max} = 0\f$ (i.e. all 57 : * characteristics move in the same direction) the HLL boundary correction 58 : * reduces to pure upwinding. 59 : * 60 : * \note 61 : * - In the strong form the `dg_boundary_terms` function returns 62 : * \f$G - F_\text{int}\f$ 63 : * - Some references use \f$S\f$ instead of \f$\lambda\f$ for the 64 : * signal/characteristic speeds 65 : */ 66 1 : class Hll final : public BoundaryCorrection { 67 : private: 68 0 : struct CharSpeed : db::SimpleTag { 69 0 : using type = Scalar<DataVector>; 70 : }; 71 : 72 : public: 73 0 : using options = tmpl::list<>; 74 0 : static constexpr Options::String help = { 75 : "Computes the HLL boundary correction term for the Burgers system."}; 76 : 77 0 : Hll() = default; 78 0 : Hll(const Hll&) = default; 79 0 : Hll& operator=(const Hll&) = default; 80 0 : Hll(Hll&&) = default; 81 0 : Hll& operator=(Hll&&) = default; 82 0 : ~Hll() override = default; 83 : 84 : /// \cond 85 : explicit Hll(CkMigrateMessage* msg); 86 : using PUP::able::register_constructor; 87 : WRAPPED_PUPable_decl_template(Hll); // NOLINT 88 : /// \endcond 89 0 : void pup(PUP::er& p) override; // NOLINT 90 : 91 0 : std::unique_ptr<BoundaryCorrection> get_clone() const override; 92 : 93 0 : using dg_package_field_tags = 94 : tmpl::list<Tags::U, ::Tags::NormalDotFlux<Tags::U>, CharSpeed>; 95 0 : using dg_package_data_temporary_tags = tmpl::list<>; 96 0 : using dg_package_data_volume_tags = tmpl::list<>; 97 0 : using dg_boundary_terms_volume_tags = tmpl::list<>; 98 : 99 0 : static double dg_package_data( 100 : gsl::not_null<Scalar<DataVector>*> packaged_u, 101 : gsl::not_null<Scalar<DataVector>*> packaged_normal_dot_flux, 102 : gsl::not_null<Scalar<DataVector>*> packaged_char_speed, 103 : const Scalar<DataVector>& u, 104 : const tnsr::I<DataVector, 1, Frame::Inertial>& flux_u, 105 : const tnsr::i<DataVector, 1, Frame::Inertial>& normal_covector, 106 : const std::optional<tnsr::I<DataVector, 1, Frame::Inertial>>& 107 : mesh_velocity, 108 : const std::optional<Scalar<DataVector>>& normal_dot_mesh_velocity); 109 : 110 0 : static void dg_boundary_terms( 111 : gsl::not_null<Scalar<DataVector>*> boundary_correction_u, 112 : const Scalar<DataVector>& u_int, 113 : const Scalar<DataVector>& normal_dot_flux_u_int, 114 : const Scalar<DataVector>& abs_char_speed_int, 115 : const Scalar<DataVector>& u_ext, 116 : const Scalar<DataVector>& normal_dot_flux_u_ext, 117 : const Scalar<DataVector>& abs_char_speed_ext, 118 : dg::Formulation dg_formulation); 119 : }; 120 : } // namespace Burgers::BoundaryCorrections