Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <array> 7 : #include <cstddef> 8 : #include <limits> 9 : #include <memory> 10 : #include <utility> 11 : 12 : #include "DataStructures/DataBox/PrefixHelpers.hpp" 13 : #include "DataStructures/DataBox/Prefixes.hpp" 14 : #include "DataStructures/Tensor/TypeAliases.hpp" 15 : #include "Domain/Structure/DirectionalIdMap.hpp" 16 : #include "Domain/Tags.hpp" 17 : #include "Evolution/DgSubcell/Tags/GhostDataForReconstruction.hpp" 18 : #include "Evolution/DgSubcell/Tags/Inactive.hpp" 19 : #include "Evolution/DgSubcell/Tags/Mesh.hpp" 20 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/FiniteDifference/ReconstructWork.hpp" 21 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/FiniteDifference/Reconstructor.hpp" 22 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp" 23 : #include "Options/String.hpp" 24 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp" 25 : #include "PointwiseFunctions/Hydro/Tags.hpp" 26 : #include "Utilities/Serialization/CharmPupable.hpp" 27 : #include "Utilities/TMPL.hpp" 28 : 29 : /// \cond 30 : class DataVector; 31 : template <size_t Dim> 32 : class Direction; 33 : template <size_t Dim> 34 : class Element; 35 : template <size_t Dim> 36 : class ElementId; 37 : namespace EquationsOfState { 38 : template <bool IsRelativistic, size_t ThermodynamicDim> 39 : class EquationOfState; 40 : } // namespace EquationsOfState 41 : template <size_t Dim> 42 : class Mesh; 43 : namespace gsl { 44 : template <typename T> 45 : class not_null; 46 : } // namespace gsl 47 : namespace PUP { 48 : class er; 49 : } // namespace PUP 50 : template <typename TagsList> 51 : class Variables; 52 : namespace evolution::dg::subcell { 53 : class GhostData; 54 : } // namespace evolution::dg::subcell 55 : /// \endcond 56 : 57 : namespace grmhd::ValenciaDivClean::fd { 58 : /*! 59 : * \brief Fifth order monotonicity-preserving (MP5) reconstruction. See 60 : * ::fd::reconstruction::monotonicity_preserving_5() for details. 61 : * 62 : */ 63 1 : class MonotonicityPreserving5Prim : public Reconstructor { 64 : private: 65 0 : using prims_to_reconstruct_tags = 66 : tmpl::list<hydro::Tags::RestMassDensity<DataVector>, 67 : hydro::Tags::ElectronFraction<DataVector>, 68 : hydro::Tags::Temperature<DataVector>, 69 : hydro::Tags::LorentzFactorTimesSpatialVelocity<DataVector, 3>, 70 : hydro::Tags::MagneticField<DataVector, 3>, 71 : hydro::Tags::DivergenceCleaningField<DataVector>>; 72 : 73 : public: 74 0 : static constexpr size_t dim = 3; 75 : 76 0 : struct Alpha { 77 0 : using type = double; 78 0 : static constexpr Options::String help = { 79 : "The parameter used in an intermediate reconstruction step to impose " 80 : "monotonicity; typically Alpha=4.0 is used. Note that in principle the " 81 : "CFL number must be not bigger than 1/(1+Alpha). See the original text " 82 : "Suresh & Huynh (1997) for the details"}; 83 : }; 84 0 : struct Epsilon { 85 0 : using type = double; 86 0 : static constexpr Options::String help = { 87 : "A small tolerance value by which limiting process is turned on and " 88 : "off. Suresh & Huynh (1997) suggests 1e-10, but for hydro simulations " 89 : "with atmosphere treatment setting Epsilon=0.0 would be safe."}; 90 : }; 91 : 92 0 : using options = tmpl::list<Alpha, Epsilon>; 93 0 : static constexpr Options::String help{ 94 : "MP5 reconstruction scheme using primitive variables."}; 95 : 96 0 : MonotonicityPreserving5Prim() = default; 97 0 : MonotonicityPreserving5Prim(MonotonicityPreserving5Prim&&) = default; 98 0 : MonotonicityPreserving5Prim& operator=(MonotonicityPreserving5Prim&&) = 99 : default; 100 0 : MonotonicityPreserving5Prim(const MonotonicityPreserving5Prim&) = default; 101 0 : MonotonicityPreserving5Prim& operator=(const MonotonicityPreserving5Prim&) = 102 : default; 103 0 : ~MonotonicityPreserving5Prim() override = default; 104 : 105 0 : MonotonicityPreserving5Prim(double alpha, double epsilon); 106 : 107 0 : explicit MonotonicityPreserving5Prim(CkMigrateMessage* msg); 108 : 109 0 : WRAPPED_PUPable_decl_base_template(Reconstructor, 110 : MonotonicityPreserving5Prim); 111 : 112 0 : auto get_clone() const -> std::unique_ptr<Reconstructor> override; 113 : 114 0 : static constexpr bool use_adaptive_order = false; 115 : 116 0 : void pup(PUP::er& p) override; 117 : 118 0 : size_t ghost_zone_size() const override { return 3; } 119 : 120 0 : using reconstruction_argument_tags = 121 : tmpl::list<::Tags::Variables<hydro::grmhd_tags<DataVector>>, 122 : hydro::Tags::GrmhdEquationOfState, domain::Tags::Element<dim>, 123 : evolution::dg::subcell::Tags::GhostDataForReconstruction<dim>, 124 : evolution::dg::subcell::Tags::Mesh<dim>>; 125 : 126 : template <size_t ThermodynamicDim> 127 0 : void reconstruct( 128 : gsl::not_null<std::array<Variables<tags_list_for_reconstruct>, dim>*> 129 : vars_on_lower_face, 130 : gsl::not_null<std::array<Variables<tags_list_for_reconstruct>, dim>*> 131 : vars_on_upper_face, 132 : const Variables<hydro::grmhd_tags<DataVector>>& volume_prims, 133 : const EquationsOfState::EquationOfState<true, ThermodynamicDim>& eos, 134 : const Element<dim>& element, 135 : const DirectionalIdMap<dim, evolution::dg::subcell::GhostData>& 136 : ghost_data, 137 : const Mesh<dim>& subcell_mesh) const; 138 : 139 : template <size_t ThermodynamicDim> 140 0 : void reconstruct_fd_neighbor( 141 : gsl::not_null<Variables<tags_list_for_reconstruct>*> vars_on_face, 142 : const Variables<hydro::grmhd_tags<DataVector>>& subcell_volume_prims, 143 : const EquationsOfState::EquationOfState<true, ThermodynamicDim>& eos, 144 : const Element<dim>& element, 145 : const DirectionalIdMap<dim, evolution::dg::subcell::GhostData>& 146 : ghost_data, 147 : const Mesh<dim>& subcell_mesh, 148 : const Direction<dim> direction_to_reconstruct) const; 149 : 150 : private: 151 : // NOLINTNEXTLINE(readability-redundant-declaration) 152 0 : friend bool operator==(const MonotonicityPreserving5Prim& lhs, 153 : const MonotonicityPreserving5Prim& rhs); 154 0 : friend bool operator!=(const MonotonicityPreserving5Prim& lhs, 155 : const MonotonicityPreserving5Prim& rhs); 156 : 157 0 : double alpha_ = std::numeric_limits<double>::signaling_NaN(); 158 0 : double epsilon_ = std::numeric_limits<double>::signaling_NaN(); 159 : }; 160 : 161 : } // namespace grmhd::ValenciaDivClean::fd