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_;
94 template <
int dim,
typename Number =
double>
147 using Bounds = std::array<Number, n_bounds>;
155 : hyperbolic_system(hyperbolic_system)
156 , parameters(parameters)
157 , precomputed_values(precomputed_values)
164 void reset(
const unsigned int i,
175 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
189 const Bounds &bounds_right);
212 const Number t_min = Number(0.),
213 const Number t_max = Number(1.));
244 Number rho_relaxation_numerator;
245 Number rho_relaxation_denominator;
255 template <
int dim,
typename Number>
256 DEAL_II_ALWAYS_INLINE
inline void
265 auto &[rho_min, rho_max, s_min] = bounds_;
267 rho_min = Number(std::numeric_limits<ScalarNumber>::max());
268 rho_max = Number(0.);
269 s_min = Number(std::numeric_limits<ScalarNumber>::max());
273 rho_relaxation_numerator = Number(0.);
274 rho_relaxation_denominator = Number(0.);
275 s_interp_max = Number(0.);
279 template <
int dim,
typename Number>
281 const unsigned int *js,
284 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
291 Assert(std::max(affine_shift.norm(), Number(0.)) == Number(0.),
292 dealii::ExcNotImplemented());
294 const auto view = hyperbolic_system.view<dim, Number>();
297 auto &[rho_min, rho_max, s_min] = bounds_;
299 const auto rho_i = view.density(U_i);
300 const auto m_i = view.momentum(U_i);
301 const auto rho_j = view.density(U_j);
302 const auto m_j = view.momentum(U_j);
303 const auto rho_affine_shift = view.density(affine_shift);
306 const auto rho_ij_bar =
307 ScalarNumber(0.5) * (rho_i + rho_j + (m_i - m_j) * scaled_c_ij) +
310 rho_min = std::min(rho_min, rho_ij_bar);
311 rho_max = std::max(rho_max, rho_ij_bar);
313 const auto &[s_j, eta_j] =
314 precomputed_values.template get_tensor<Number, precomputed_type>(js);
315 s_min = std::min(s_min, s_j);
320 const auto beta_ij = Number(1.);
321 rho_relaxation_numerator += beta_ij * (rho_i + rho_j);
322 rho_relaxation_denominator += std::abs(beta_ij);
324 const Number s_interp =
326 s_interp_max = std::max(s_interp_max, s_interp);
330 template <
int dim,
typename Number>
331 DEAL_II_ALWAYS_INLINE
inline auto
334 auto relaxed_bounds = bounds_;
335 auto &[rho_min, rho_max, s_min] = relaxed_bounds;
339 Number r_i = std::sqrt(hd_i);
340 if constexpr (dim == 2)
341 r_i = dealii::Utilities::fixed_power<3>(std::sqrt(r_i));
342 else if constexpr (dim == 1)
343 r_i = dealii::Utilities::fixed_power<3>(r_i);
344 r_i *= parameters.relaxation_factor();
346 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
347 const Number rho_relaxation =
348 std::abs(rho_relaxation_numerator) /
349 (std::abs(rho_relaxation_denominator) + Number(eps));
351 const auto relaxation =
352 ScalarNumber(2. * parameters.relaxation_factor()) * rho_relaxation;
354 rho_min = std::max((Number(1.) - r_i) * rho_min, rho_min - relaxation);
355 rho_max = std::min((Number(1.) + r_i) * rho_max, rho_max + relaxation);
357 const auto entropy_relaxation =
358 parameters.relaxation_factor() * (s_interp_max - s_min);
360 s_min = std::max((Number(1.) - r_i) * s_min, s_min - entropy_relaxation);
362 return relaxed_bounds;
366 template <
int dim,
typename Number>
367 DEAL_II_ALWAYS_INLINE
inline auto
371 const auto &[rho_min_l, rho_max_l, s_min_l] = bounds_left;
372 const auto &[rho_min_r, rho_max_r, s_min_r] = bounds_right;
374 return {std::min(rho_min_l, rho_min_r),
375 std::max(rho_max_l, rho_max_r),
376 std::min(s_min_l, s_min_r)};
380 template <
int dim,
typename Number>
381 DEAL_II_ALWAYS_INLINE
inline bool
387 AssertThrow(
false, dealii::ExcNotImplemented());
typename get_value_type< Number >::type ScalarNumber
Vectors::MultiComponentVector< ScalarNumber, n_precomputed_values > PrecomputedVector
static constexpr unsigned int problem_dimension
dealii::Tensor< 1, problem_dimension, Number > state_type
std::array< Number, n_precomputed_values > precomputed_type
flux_type flux_contribution_type
ACCESSOR_READ_ONLY(iterations)
ACCESSOR_READ_ONLY(newton_max_iterations)
ACCESSOR_READ_ONLY(newton_tolerance)
ACCESSOR_READ_ONLY(relaxation_factor)
LimiterParameters(const std::string &subsection="/Limiter")
Limiter(const HyperbolicSystem &hyperbolic_system, const Parameters ¶meters, const PrecomputedVector &precomputed_values)
void reset(const unsigned int i, const state_type &U_i, const flux_contribution_type &flux_i)
typename View::PrecomputedVector PrecomputedVector
static Bounds combine_bounds(const Bounds &bounds_left, const Bounds &bounds_right)
static constexpr auto problem_dimension
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)
typename View::precomputed_type precomputed_type
typename View::ScalarNumber ScalarNumber
typename View::state_type state_type
LimiterParameters< ScalarNumber > Parameters
Bounds bounds(const Number hd_i) const
static constexpr unsigned int n_bounds
std::array< Number, n_bounds > Bounds
typename View::flux_contribution_type flux_contribution_type
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.))
static bool is_in_invariant_domain(const HyperbolicSystem &hyperbolic_system, const Bounds &bounds, const state_type &U)