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 <tuple>
8 :
9 : #include "DataStructures/Tensor/TypeAliases.hpp"
10 : #include "DataStructures/VariablesTag.hpp"
11 : #include "Domain/Tags.hpp"
12 : #include "Evolution/DgSubcell/RdmpTciData.hpp"
13 : #include "Evolution/DgSubcell/Tags/DataForRdmpTci.hpp"
14 : #include "Evolution/DgSubcell/Tags/Inactive.hpp"
15 : #include "Evolution/DgSubcell/Tags/Mesh.hpp"
16 : #include "Evolution/DgSubcell/Tags/SubcellOptions.hpp"
17 : #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
18 : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
19 : #include "PointwiseFunctions/Hydro/Tags.hpp"
20 : #include "Utilities/TMPL.hpp"
21 :
22 : /// \cond
23 : class DataVector;
24 : template <size_t Dim>
25 : class Mesh;
26 : namespace gsl {
27 : template <typename T>
28 : class not_null;
29 : } // namespace gsl
30 : template <typename TagsList>
31 : class Variables;
32 : /// \endcond
33 :
34 : namespace NewtonianEuler::subcell {
35 : /*!
36 : * \brief Troubled-cell indicator applied to the finite difference subcell
37 : * solution to check if the corresponding DG solution is admissible.
38 : *
39 : * Computes the primitive variables on the DG and subcell grids, mutating the
40 : * subcell/active primitive variables in the DataBox. Then,
41 : * - apply RDMP TCI to the mass and energy density
42 : * - if the minimum density or pressure on either the DG or subcell mesh are
43 : * below \f$10^{-18}\f$, marks the element as troubled and returns. We check
44 : * both the FD and DG grids since when a discontinuity is inside the element
45 : * oscillations in the DG solution can result in negative values that aren't
46 : * present in the FD solution.
47 : * - runs the Persson TCI on the mass and energy density on the DG grid. The
48 : * reason for applying the Persson TCI to both the mass and energy density is
49 : * to flag cells at contact discontinuities. The Persson TCI only works with
50 : * spectral-type methods and is a direct check of whether or not the DG
51 : * solution is a good representation of the underlying data.
52 : *
53 : * Please note that the TCI is run after the subcell solution has been
54 : * reconstructed to the DG grid, and so `Inactive<Tag>` is the updated DG
55 : * solution.
56 : */
57 : template <size_t Dim>
58 1 : class TciOnFdGrid {
59 : private:
60 0 : using MassDensityCons = NewtonianEuler::Tags::MassDensityCons;
61 0 : using EnergyDensity = NewtonianEuler::Tags::EnergyDensity;
62 0 : using MomentumDensity = NewtonianEuler::Tags::MomentumDensity<Dim>;
63 :
64 0 : using MassDensity = hydro::Tags::RestMassDensity<DataVector>;
65 0 : using Velocity = hydro::Tags::SpatialVelocity<DataVector, Dim>;
66 0 : using SpecificInternalEnergy =
67 : hydro::Tags::SpecificInternalEnergy<DataVector>;
68 0 : using Pressure = hydro::Tags::Pressure<DataVector>;
69 :
70 0 : static constexpr double min_density_allowed = 1.0e-18;
71 0 : static constexpr double min_pressure_allowed = 1.0e-18;
72 :
73 : public:
74 0 : using return_tags = tmpl::list<::Tags::Variables<
75 : tmpl::list<MassDensity, Velocity, SpecificInternalEnergy, Pressure>>>;
76 0 : using argument_tags = tmpl::list<
77 : ::Tags::Variables<
78 : tmpl::list<MassDensityCons, MomentumDensity, EnergyDensity>>,
79 : hydro::Tags::EquationOfState<false, 2>, domain::Tags::Mesh<Dim>,
80 : evolution::dg::subcell::Tags::Mesh<Dim>,
81 : evolution::dg::subcell::Tags::DataForRdmpTci,
82 : evolution::dg::subcell::Tags::SubcellOptions<Dim>>;
83 :
84 0 : static std::tuple<bool, evolution::dg::subcell::RdmpTciData> apply(
85 : gsl::not_null<Variables<
86 : tmpl::list<MassDensity, Velocity, SpecificInternalEnergy, Pressure>>*>
87 : subcell_grid_prim_vars,
88 : const Variables<tmpl::list<MassDensityCons, MomentumDensity,
89 : EnergyDensity>>& subcell_vars,
90 : const EquationsOfState::EquationOfState<false, 2>& eos,
91 : const Mesh<Dim>& dg_mesh, const Mesh<Dim>& subcell_mesh,
92 : const evolution::dg::subcell::RdmpTciData& past_rdmp_tci_data,
93 : const evolution::dg::subcell::SubcellOptions& subcell_options,
94 : double persson_exponentconst, bool need_rdmp_data_only);
95 : };
96 : } // namespace NewtonianEuler::subcell
|