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<ScalarNumber, double>::value)
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;
187 void reset(
const unsigned int i,
198 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
227 const Number t_min = Number(0.),
228 const Number t_max = Number(1.));
244 Number rho_relaxation_numerator;
245 Number rho_relaxation_denominator;
259 template <
int dim,
typename Number>
260 DEAL_II_ALWAYS_INLINE
inline auto
264 const auto view = hyperbolic_system.view<dim, Number>();
265 const auto rho_i = view.density(U_i);
266 const auto &[p_i, gamma_min_i, s_i, eta_i] =
267 precomputed_values.template get_tensor<Number, precomputed_type>(i);
276 template <
int dim,
typename Number>
280 const auto &[rho_min_l, rho_max_l, s_min_l, gamma_min_l] = bounds_left;
281 const auto &[rho_min_r, rho_max_r, s_min_r, gamma_min_r] = bounds_right;
283 return {std::min(rho_min_l, rho_min_r),
284 std::max(rho_max_l, rho_max_r),
285 std::min(s_min_l, s_min_r),
286 std::min(gamma_min_l, gamma_min_r)};
290 template <
int dim,
typename Number>
291 DEAL_II_ALWAYS_INLINE
inline void
301 auto &[rho_min, rho_max, s_min, gamma_min] = bounds_;
303 rho_min = Number(std::numeric_limits<ScalarNumber>::max());
304 rho_max = Number(0.);
305 s_min = Number(std::numeric_limits<ScalarNumber>::max());
307 const auto &[p_i, gamma_min_i, s_i, eta_i] =
308 precomputed_values.template get_tensor<Number, precomputed_type>(i);
310 gamma_min = gamma_min_i;
314 rho_relaxation_numerator = Number(0.);
315 rho_relaxation_denominator = Number(0.);
316 s_interp_max = Number(0.);
320 template <
int dim,
typename Number>
322 const unsigned int *js,
325 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
332 Assert(std::max(affine_shift.norm(), Number(0.)) == Number(0.),
333 dealii::ExcNotImplemented());
335 const auto view = hyperbolic_system.view<dim, Number>();
338 auto &[rho_min, rho_max, s_min, gamma_min] = bounds_;
340 const auto rho_i = view.density(U_i);
341 const auto rho_j = view.density(U_j);
344 const auto U_ij_bar =
349 const auto rho_ij_bar = view.density(U_ij_bar);
353 rho_min = std::min(rho_min, rho_ij_bar);
354 rho_max = std::max(rho_max, rho_ij_bar);
359 const auto beta_ij = Number(1.);
360 rho_relaxation_numerator += beta_ij * (rho_i + rho_j);
361 rho_relaxation_denominator += std::abs(beta_ij);
365 if (view.compute_strict_bounds()) {
376 const auto s_j = view.surrogate_specific_entropy(U_j, gamma_min);
378 const auto s_ij_bar =
379 view.surrogate_specific_entropy(U_ij_bar, gamma_min);
381 const Number s_interp = view.surrogate_specific_entropy(
384 s_min = std::min(s_min, s_j);
385 s_min = std::min(s_min, s_ij_bar);
386 s_interp_max = std::max(s_interp_max, s_interp);
395 const auto [p_j, gamma_min_j, s_j, eta_j] =
396 precomputed_values.template get_tensor<Number, precomputed_type>(
399 const auto s_ij_bar =
400 view.surrogate_specific_entropy(U_ij_bar, gamma_min);
402 s_min = std::min(s_min, s_j);
403 s_min = std::min(s_min, s_ij_bar);
404 s_interp_max = std::max(s_interp_max, s_ij_bar);
409 template <
int dim,
typename Number>
410 DEAL_II_ALWAYS_INLINE
inline auto
413 const auto view = hyperbolic_system.view<dim, Number>();
415 auto relaxed_bounds = bounds_;
416 auto &[rho_min, rho_max, s_min, gamma_min] = relaxed_bounds;
420 Number r_i = std::sqrt(hd_i);
421 if constexpr (dim == 2)
422 r_i = dealii::Utilities::fixed_power<3>(std::sqrt(r_i));
423 else if constexpr (dim == 1)
424 r_i = dealii::Utilities::fixed_power<3>(r_i);
425 r_i *= parameters.relaxation_factor();
427 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
428 const Number rho_relaxation =
429 std::abs(rho_relaxation_numerator) /
430 (std::abs(rho_relaxation_denominator) + Number(eps));
432 const auto relaxation =
433 ScalarNumber(2. * parameters.relaxation_factor()) * rho_relaxation;
435 rho_min = std::max((Number(1.) - r_i) * rho_min, rho_min - relaxation);
436 rho_max = std::min((Number(1.) + r_i) * rho_max, rho_max + relaxation);
438 const auto entropy_relaxation =
439 parameters.relaxation_factor() * (s_interp_max - s_min);
441 s_min = std::max((Number(1.) - r_i) * s_min, s_min - entropy_relaxation);
449 const auto numerator = (gamma_min + Number(1.)) * rho_max;
450 const auto interpolation_b = view.eos_interpolation_b();
451 const auto denominator =
452 gamma_min - Number(1.) +
ScalarNumber(2.) * interpolation_b * rho_max;
453 const auto upper_bound = numerator / denominator;
455 rho_max = std::min(upper_bound, rho_max);
457 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)
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
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::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.))
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)