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;
160 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
181 const Number t_min = Number(0.),
182 const Number t_max = Number(1.))
const;
198 Number u_relaxation_numerator;
199 Number u_relaxation_denominator;
211 template <
int dim,
typename Number>
212 DEAL_II_ALWAYS_INLINE
inline auto
216 const auto view = hyperbolic_system.view<dim, Number>();
217 const auto u_i = view.state(U_i);
222 template <
int dim,
typename Number>
226 const auto &[u_min_l, u_max_l] = bounds_left;
227 const auto &[u_min_r, u_max_r] = bounds_right;
229 return {std::min(u_min_l, u_min_r), std::max(u_max_l, u_max_r)};
233 template <
int dim,
typename Number>
234 DEAL_II_ALWAYS_INLINE
inline auto
236 const Number &hd)
const ->
Bounds
238 auto relaxed_bounds = bounds;
239 auto &[u_min, u_max] = relaxed_bounds;
243 Number r = std::sqrt(hd);
244 if constexpr (dim == 2)
245 r = dealii::Utilities::fixed_power<3>(std::sqrt(r));
246 else if constexpr (dim == 1)
247 r = dealii::Utilities::fixed_power<3>(r);
248 r *= parameters.relaxation_factor();
250 u_min = std::min((Number(1.) - r) * u_min, (Number(1.) + r) * u_min);
251 u_max = std::max((Number(1.) + r) * u_max, (Number(1.) - r) * u_max);
253 return relaxed_bounds;
257 template <
int dim,
typename Number>
258 DEAL_II_ALWAYS_INLINE
inline void
268 auto &[u_min, u_max] = bounds_;
270 u_min = Number(std::numeric_limits<ScalarNumber>::max());
271 u_max = Number(std::numeric_limits<ScalarNumber>::lowest());
275 u_relaxation_numerator = Number(0.);
276 u_relaxation_denominator = Number(0.);
280 template <
int dim,
typename Number>
282 const unsigned int * ,
285 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
288 const auto view = hyperbolic_system.view<dim, Number>();
291 auto &[u_min, u_max] = bounds_;
293 const auto u_i = view.state(U_i);
294 const auto u_j = view.state(U_j);
296 const auto U_ij_bar =
301 const auto u_ij_bar = view.state(U_ij_bar);
305 u_min = std::min(u_min, u_ij_bar);
306 u_max = std::max(u_max, u_ij_bar);
311 const auto beta_ij = Number(1.);
312 u_relaxation_numerator += beta_ij * (u_i + u_j);
313 u_relaxation_denominator += std::abs(beta_ij);
317 template <
int dim,
typename Number>
318 DEAL_II_ALWAYS_INLINE
inline auto
321 const auto &[u_min, u_max] = bounds_;
323 auto relaxed_bounds = fully_relax_bounds(bounds_, hd_i);
324 auto &[u_min_relaxed, u_max_relaxed] = relaxed_bounds;
328 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
330 const Number u_relaxation =
332 std::abs(u_relaxation_numerator) /
333 (std::abs(u_relaxation_denominator) + Number(eps));
335 u_min_relaxed = std::max(u_min_relaxed, u_min - u_relaxation);
336 u_max_relaxed = std::min(u_max_relaxed, u_max + u_relaxation);
338 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
Bounds fully_relax_bounds(const Bounds &bounds, const Number &hd) const
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)
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
static constexpr unsigned int n_bounds
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)