10#include <compile_time_options.h>
19 template <
typename ScalarNumber =
double>
24 : ParameterAcceptor(subsection)
28 "iterations", iterations_,
"Number of limiter iterations");
30 if constexpr (std::is_same_v<ScalarNumber, double>)
31 newton_tolerance_ = 1.e-10;
33 newton_tolerance_ = 1.e-4;
34 add_parameter(
"newton tolerance",
36 "Tolerance for the quadratic newton stopping criterion");
38 newton_max_iterations_ = 2;
39 add_parameter(
"newton max iterations",
40 newton_max_iterations_,
41 "Maximal number of quadratic newton iterations performed "
44 relaxation_factor_ = ScalarNumber(1.);
45 add_parameter(
"relaxation factor",
47 "Factor for scaling the relaxation window with r_i = "
48 "factor * (m_i/|Omega|)^(1.5/d).");
57 unsigned int iterations_;
58 ScalarNumber newton_tolerance_;
59 unsigned int newton_max_iterations_;
60 ScalarNumber relaxation_factor_;
96 template <
int dim,
typename Number =
double>
135 using Bounds = std::array<Number, n_bounds>;
143 : hyperbolic_system(hyperbolic_system)
144 , parameters(parameters)
145 , precomputed_values(precomputed_values)
162 const Bounds &bounds_right)
const;
197 void reset(
const unsigned int i,
208 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
238 const Number t_min = Number(0.),
239 const Number t_max = Number(1.))
const;
255 Number rho_relaxation_numerator;
256 Number rho_relaxation_denominator;
270 template <
int dim,
typename Number>
271 DEAL_II_ALWAYS_INLINE
inline auto
275 const auto view = hyperbolic_system.view<dim, Number>();
276 const auto rho_i = view.density(U_i);
277 const auto &[p_i, gamma_min_i, s_i, eta_i] =
278 precomputed_values.template get_tensor<Number, precomputed_type>(i);
287 template <
int dim,
typename Number>
291 const auto &[rho_min_l, rho_max_l, s_min_l, gamma_min_l] = bounds_left;
292 const auto &[rho_min_r, rho_max_r, s_min_r, gamma_min_r] = bounds_right;
294 return {std::min(rho_min_l, rho_min_r),
295 std::max(rho_max_l, rho_max_r),
296 std::min(s_min_l, s_min_r),
297 std::min(gamma_min_l, gamma_min_r)};
301 template <
int dim,
typename Number>
302 DEAL_II_ALWAYS_INLINE
inline auto
304 const Number &hd)
const ->
Bounds
306 const auto view = hyperbolic_system.view<dim, Number>();
308 const auto &[rho_min, rho_max, s_min, gamma_min] = bounds;
310 auto relaxed_bounds = bounds;
311 auto &[rho_min_relaxed, rho_max_relaxed, s_min_relaxed, g_m_relaxed] =
316 Number r = std::sqrt(hd);
317 if constexpr (dim == 2)
318 r = dealii::Utilities::fixed_power<3>(std::sqrt(r));
319 else if constexpr (dim == 1)
320 r = dealii::Utilities::fixed_power<3>(r);
321 r *= parameters.relaxation_factor();
323 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
324 rho_min_relaxed *= std::max(Number(1.) - r, Number(eps));
325 rho_max_relaxed *= (Number(1.) + r);
326 s_min_relaxed *= std::max(Number(1.) - r, Number(eps));
334 const auto numerator = (gamma_min + Number(1.)) * rho_max;
335 const auto interpolation_b = view.eos_interpolation_b();
336 const auto denominator =
337 gamma_min - Number(1.) +
ScalarNumber(2.) * interpolation_b * rho_max;
338 const auto rho_compressibility_bound = numerator / denominator;
340 rho_max_relaxed = std::min(rho_compressibility_bound, rho_max_relaxed);
342 return relaxed_bounds;
346 template <
int dim,
typename Number>
347 DEAL_II_ALWAYS_INLINE
inline void
357 auto &[rho_min, rho_max, s_min, gamma_min] = bounds_;
359 rho_min = Number(std::numeric_limits<ScalarNumber>::max());
360 rho_max = Number(0.);
361 s_min = Number(std::numeric_limits<ScalarNumber>::max());
363 const auto &[p_i, gamma_min_i, s_i, eta_i] =
364 precomputed_values.template get_tensor<Number, precomputed_type>(i);
366 gamma_min = gamma_min_i;
370 rho_relaxation_numerator = Number(0.);
371 rho_relaxation_denominator = Number(0.);
372 s_interp_max = Number(0.);
376 template <
int dim,
typename Number>
378 const unsigned int *js,
381 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
388 Assert(std::max(affine_shift.norm(), Number(0.)) == Number(0.),
389 dealii::ExcNotImplemented());
391 const auto view = hyperbolic_system.view<dim, Number>();
394 auto &[rho_min, rho_max, s_min, gamma_min] = bounds_;
396 const auto rho_i = view.density(U_i);
397 const auto rho_j = view.density(U_j);
400 const auto U_ij_bar =
405 const auto rho_ij_bar = view.density(U_ij_bar);
409 rho_min = std::min(rho_min, rho_ij_bar);
410 rho_max = std::max(rho_max, rho_ij_bar);
415 const auto beta_ij = Number(1.);
416 rho_relaxation_numerator += beta_ij * (rho_i + rho_j);
417 rho_relaxation_denominator += std::abs(beta_ij);
421 if (view.compute_strict_bounds()) {
432 const auto s_j = view.surrogate_specific_entropy(U_j, gamma_min);
434 const auto s_ij_bar =
435 view.surrogate_specific_entropy(U_ij_bar, gamma_min);
437 const Number s_interp = view.surrogate_specific_entropy(
440 s_min = std::min(s_min, s_j);
441 s_min = std::min(s_min, s_ij_bar);
442 s_interp_max = std::max(s_interp_max, s_interp);
451 const auto [p_j, gamma_min_j, s_j, eta_j] =
452 precomputed_values.template get_tensor<Number, precomputed_type>(
455 const auto s_ij_bar =
456 view.surrogate_specific_entropy(U_ij_bar, gamma_min);
458 s_min = std::min(s_min, s_j);
459 s_min = std::min(s_min, s_ij_bar);
460 s_interp_max = std::max(s_interp_max, s_ij_bar);
465 template <
int dim,
typename Number>
466 DEAL_II_ALWAYS_INLINE
inline auto
469 const auto &[rho_min, rho_max, s_min, gamma_min] = bounds_;
471 auto relaxed_bounds = fully_relax_bounds(bounds_, hd_i);
472 auto &[rho_min_relaxed, rho_max_relaxed, s_min_relaxed, g_m_relaxed] =
477 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
479 const auto rho_relaxation =
481 std::abs(rho_relaxation_numerator) /
482 (std::abs(rho_relaxation_denominator) + Number(eps));
484 const auto entropy_relaxation =
485 parameters.relaxation_factor() * (s_interp_max - s_min);
487 rho_min_relaxed = std::max(rho_min_relaxed, rho_min - rho_relaxation);
488 rho_max_relaxed = std::min(rho_max_relaxed, rho_max + rho_relaxation);
489 s_min_relaxed = std::max(s_min_relaxed, s_min - entropy_relaxation);
491 return relaxed_bounds;
dealii::Tensor< 1, problem_dimension, Number > state_type
typename get_value_type< Number >::type ScalarNumber
static constexpr unsigned int problem_dimension
flux_type flux_contribution_type
Vectors::MultiComponentVector< ScalarNumber, n_precomputed_values > PrecomputedVector
std::array< Number, n_precomputed_values > precomputed_type
LimiterParameters(const std::string &subsection="/Limiter")
ACCESSOR_READ_ONLY(iterations)
ACCESSOR_READ_ONLY(newton_max_iterations)
ACCESSOR_READ_ONLY(relaxation_factor)
ACCESSOR_READ_ONLY(newton_tolerance)
Bounds fully_relax_bounds(const Bounds &bounds, const Number &hd) const
typename View::state_type state_type
static constexpr unsigned int n_bounds
Limiter(const HyperbolicSystem &hyperbolic_system, const Parameters ¶meters, const PrecomputedVector &precomputed_values)
typename View::ScalarNumber ScalarNumber
Bounds combine_bounds(const Bounds &bounds_left, const Bounds &bounds_right) const
std::tuple< Number, bool > limit(const Bounds &bounds, const state_type &U, const state_type &P, const Number t_min=Number(0.), const Number t_max=Number(1.)) const
typename View::flux_contribution_type flux_contribution_type
void reset(const unsigned int i, const state_type &U_i, const flux_contribution_type &flux_i)
std::array< Number, n_bounds > Bounds
void accumulate(const unsigned int *js, const state_type &U_j, const flux_contribution_type &flux_j, const dealii::Tensor< 1, dim, Number > &scaled_c_ij, const state_type &affine_shift)
Bounds projection_bounds_from_state(const unsigned int i, const state_type &U_i) const
Bounds bounds(const Number hd_i) const
LimiterParameters< ScalarNumber > Parameters
typename View::PrecomputedVector PrecomputedVector
typename View::precomputed_type precomputed_type
static constexpr auto problem_dimension
DEAL_II_ALWAYS_INLINE FT add(const FT &flux_left_ij, const FT &flux_right_ij)
DEAL_II_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > contract(const FT &flux_ij, const TT &c_ij)