10#include <compile_time_options.h>
16 namespace ScalarConservation
18 template <
typename ScalarNumber =
double>
23 : ParameterAcceptor(subsection)
27 "iterations", iterations_,
"Number of limiter iterations");
29 relaxation_factor_ = ScalarNumber(1.);
30 add_parameter(
"relaxation factor",
32 "Factor for scaling the relaxation window with r_i = "
33 "factor * (m_i/|Omega|)^(1.5/d).");
40 unsigned int iterations_;
41 ScalarNumber relaxation_factor_;
50 template <
int dim,
typename Number =
double>
90 using Bounds = std::array<Number, n_bounds>;
98 : hyperbolic_system(hyperbolic_system)
99 , parameters(parameters)
100 , precomputed_values(precomputed_values)
117 const Bounds &bounds_right)
const;
153 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
174 const Number t_min = Number(0.),
175 const Number t_max = Number(1.));
191 Number u_relaxation_numerator;
192 Number u_relaxation_denominator;
204 template <
int dim,
typename Number>
205 DEAL_II_ALWAYS_INLINE
inline auto
209 const auto view = hyperbolic_system.view<dim, Number>();
210 const auto u_i = view.state(U_i);
215 template <
int dim,
typename Number>
219 const auto &[u_min_l, u_max_l] = bounds_left;
220 const auto &[u_min_r, u_max_r] = bounds_right;
222 return {std::min(u_min_l, u_min_r), std::max(u_max_l, u_max_r)};
226 template <
int dim,
typename Number>
227 DEAL_II_ALWAYS_INLINE
inline void
237 auto &[u_min, u_max] = bounds_;
239 u_min = Number(std::numeric_limits<ScalarNumber>::max());
240 u_max = Number(std::numeric_limits<ScalarNumber>::lowest());
244 u_relaxation_numerator = Number(0.);
245 u_relaxation_denominator = Number(0.);
249 template <
int dim,
typename Number>
251 const unsigned int * ,
254 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
257 const auto view = hyperbolic_system.view<dim, Number>();
260 auto &[u_min, u_max] = bounds_;
262 const auto u_i = view.state(U_i);
263 const auto u_j = view.state(U_j);
265 const auto U_ij_bar =
270 const auto u_ij_bar = view.state(U_ij_bar);
274 u_min = std::min(u_min, u_ij_bar);
275 u_max = std::max(u_max, u_ij_bar);
280 const auto beta_ij = Number(1.);
281 u_relaxation_numerator += beta_ij * (u_i + u_j);
282 u_relaxation_denominator += std::abs(beta_ij);
286 template <
int dim,
typename Number>
287 DEAL_II_ALWAYS_INLINE
inline auto
290 auto relaxed_bounds = bounds_;
291 auto &[u_min, u_max] = relaxed_bounds;
295 Number r_i = std::sqrt(hd_i);
296 if constexpr (dim == 2)
297 r_i = dealii::Utilities::fixed_power<3>(std::sqrt(r_i));
298 else if constexpr (dim == 1)
299 r_i = dealii::Utilities::fixed_power<3>(r_i);
300 r_i *= parameters.relaxation_factor();
302 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
303 const Number u_relaxation =
304 std::abs(u_relaxation_numerator) /
305 (std::abs(u_relaxation_denominator) + Number(eps));
308 std::min((Number(1.) - r_i) * u_min, (Number(1.) + r_i) * u_min),
312 std::max((Number(1.) + r_i) * u_max, (Number(1.) - r_i) * u_max),
315 return relaxed_bounds;
static constexpr unsigned int problem_dimension
std::array< Number, n_precomputed_values > precomputed_type
Vectors::MultiComponentVector< ScalarNumber, n_precomputed_values > PrecomputedVector
typename get_value_type< Number >::type ScalarNumber
dealii::Tensor< 1, problem_dimension, Number > state_type
flux_type flux_contribution_type
ACCESSOR_READ_ONLY(iterations)
LimiterParameters(const std::string &subsection="/Limiter")
ACCESSOR_READ_ONLY(relaxation_factor)
std::array< Number, n_bounds > Bounds
Limiter(const HyperbolicSystem &hyperbolic_system, const Parameters ¶meters, const PrecomputedVector &precomputed_values)
typename View::PrecomputedVector PrecomputedVector
typename View::state_type state_type
Bounds combine_bounds(const Bounds &bounds_left, const Bounds &bounds_right) const
Bounds projection_bounds_from_state(const unsigned int i, const state_type &U_i) const
void reset(const unsigned int i, const state_type &U_i, const flux_contribution_type &flux_i)
static constexpr unsigned int n_bounds
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.))
typename View::ScalarNumber ScalarNumber
static constexpr auto problem_dimension
Bounds bounds(const Number hd_i) const
typename View::flux_contribution_type flux_contribution_type
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
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)