TciOnFdGrid.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
9 #include "DataStructures/VariablesTag.hpp"
10 #include "Domain/Tags.hpp"
11 #include "Evolution/DgSubcell/Tags/Inactive.hpp"
12 #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
13 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
14 #include "PointwiseFunctions/Hydro/Tags.hpp"
15 #include "Utilities/TMPL.hpp"
16 
17 /// \cond
18 class DataVector;
19 template <size_t Dim>
20 class Mesh;
21 namespace gsl {
22 template <typename T>
23 class not_null;
24 } // namespace gsl
25 template <typename TagsList>
26 class Variables;
27 /// \endcond
28 
29 namespace NewtonianEuler::subcell {
30 /*!
31  * \brief Troubled-cell indicator applied to the finite difference subcell
32  * solution to check if the corresponding DG solution is admissible.
33  *
34  * Computes the primitive variables on the DG and subcell grids, mutating the
35  * subcell/active primitive variables in the DataBox. Then,
36  * - if the minimum density or pressure on either the DG or subcell mesh are
37  * below \f$10^{-18}\f$, marks the element as troubled and returns. We check
38  * both the FD and DG grids since when a discontinuity is inside the element
39  * oscillations in the DG solution can result in negative values that aren't
40  * present in the FD solution.
41  * - runs the Persson TCI on the density and pressure on the DG grid. The reason
42  * for applying the Persson TCI to both the density and pressure is to flag
43  * cells at contact discontinuities. The Persson TCI only works with
44  * spectral-type methods and is a direct check of whether or not the DG
45  * solution is a good representation of the underlying data.
46  *
47  * Please note that the TCI is run after the subcell solution has been
48  * reconstructed to the DG grid, and so `Inactive<Tag>` is the updated DG
49  * solution.
50  */
51 template <size_t Dim>
52 class TciOnFdGrid {
53  private:
57 
63 
64  template <typename Tag>
66 
67  static constexpr double min_density_allowed = 1.0e-18;
68  static constexpr double min_pressure_allowed = 1.0e-18;
69 
70  public:
71  using return_tags = tmpl::list<::Tags::Variables<
72  tmpl::list<MassDensity, Velocity, SpecificInternalEnergy, Pressure>>>;
73  using argument_tags =
78 
79  template <size_t ThermodynamicDim>
80  static bool apply(
81  gsl::not_null<Variables<
82  tmpl::list<MassDensity, Velocity, SpecificInternalEnergy, Pressure>>*>
83  subcell_grid_prim_vars,
84  const Scalar<DataVector>& subcell_mass_density,
85  const tnsr::I<DataVector, Dim, Frame::Inertial>& subcell_momentum_density,
86  const Scalar<DataVector>& subcell_energy_density,
87  const Scalar<DataVector>& dg_mass_density,
88  const tnsr::I<DataVector, Dim, Frame::Inertial>& dg_momentum_density,
89  const Scalar<DataVector>& dg_energy_density,
91  const Mesh<Dim>& dg_mesh, double persson_exponent) noexcept;
92 };
93 } // namespace NewtonianEuler::subcell
EquationsOfState::EquationOfState
Base class for equations of state depending on whether or not the system is relativistic,...
Definition: EquationOfState.hpp:63
Tags.hpp
NewtonianEuler::Tags::MassDensity
The mass density of the fluid.
Definition: Tags.hpp:26
Tags::Variables
Definition: VariablesTag.hpp:21
NewtonianEuler::Tags::SpecificInternalEnergy
The specific internal energy of the fluid.
Definition: Tags.hpp:60
domain::Tags::Mesh
The computational grid of the Element in the DataBox.
Definition: Tags.hpp:107
NewtonianEuler::Tags::MassDensityCons
The mass density of the fluid (as a conservative variable).
Definition: Tags.hpp:31
NewtonianEuler::subcell
Code required by the DG-subcell/FD hybrid solver.
Definition: InitialDataTci.hpp:22
cstddef
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
NewtonianEuler::Tags::Pressure
The fluid pressure.
Definition: Tags.hpp:66
NewtonianEuler::Tags::EnergyDensity
The energy density of the fluid.
Definition: Tags.hpp:45
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:49
NewtonianEuler::Tags::MomentumDensity
The momentum density of the fluid.
Definition: Tags.hpp:37
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
TypeAliases.hpp
NewtonianEuler::subcell::TciOnFdGrid
Troubled-cell indicator applied to the finite difference subcell solution to check if the correspondi...
Definition: TciOnFdGrid.hpp:52
hydro::Tags::EquationOfStateBase
Base tag for the equation of state.
Definition: Tags.hpp:53
NewtonianEuler::Tags::Velocity
The macroscopic or flow velocity of the fluid.
Definition: Tags.hpp:51
evolution::dg::subcell::Tags::Inactive
Mark a tag as holding data for the inactive grid.
Definition: Inactive.hpp:23
gsl
Implementations from the Guideline Support Library.
Definition: ReadSpecPiecewisePolynomial.hpp:11
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13